On Mon, Jan 12, 2009 at 3:54 PM, Larry Wall <la...@wall.org> wrote:

> On Mon, Jan 12, 2009 at 01:19:12PM -0800, Jon Lang wrote:
> : As well, isn't there a way to escape a character that would otherwise
> : be interpolated?  If the intent were as you suppose, the original
> : could be rewritten as:
> :
> :   $ perl6 -e 'my $foo = "foo";say "\{" ~ $foo ~ "}"'
>
> Sure, though in any case I'd probably prefer:
>
>    $ perl6 -e 'my $foo = "foo"; say Qs/{$foo}/'
>
> : (Or would you need to escape the closing curly brace as well as the
> : opening one?)
>
> Not unless something outside of it all was attempting to count braces.
> But the P6 parser has sworn off all such activities for P6-derived
> code.  Parsing something first as a string and then again as some
> other language is generally looked upon as a Bad Plan these days.
>
> Which is, of course, why "{" is a problem now.  Perhaps use of nested
> double quotes deserves a warning.
>

masak++ was right, if you use single quotes it works properly. Here's how
you do it from a bash prompt:

$ ./perl6 -e 'my $foo = '\''foo'\''; say '\''{'\'' ~ $foo ~ '\''}'\'' '
{foo}

Notice the overly redundant single-quotes; in fact, all of those quotes are
single quotes.

-Jason "s1n" Switzer

Reply via email to