On Thu, Dec 20, 2007 at 11:35:44AM -0600, Jonathan Scott Duff wrote:
> On Thu, Dec 20, 2007 at 11:23:05AM -0600, Jonathan Scott Duff wrote:
> > Adriano answered #1 I think:  $yaml = Q:!c"{ $key: 42 }";
> Er, I just looked over the spec again and realized that Q does
> absolutely no interpolation, so it would be more like this:
>     $yaml = Q:qq:!c"{ $key: 42 }";
> or perhaps
>     $yaml = qq:!c"{ $key: 42 }";

There's also

    $yaml = qs "{ $key: 42 }";

This form also makes it easier to deal with special characters,
such as quoted yaml values, as in

    $yaml = qs /{ $key: "$value" }/;

which interpolates $key and $value but leaves the curlies and
quotation marks alone.

Just to add another perspective, PHP uses curlies inside of
double-quoted strings to indicate various forms of 
interpolation, and it doesn't seem to cause major issues
there.  But perhaps it's less frequent that PHP apps need
to put curlies in double-quoted strings.  Still, given the
very few times I've had to do this, I've never found it
overly onerous to escape the leading curly the few times I've
needed it.


Reply via email to