On Fri, Dec 02, 2005 at 09:26:12PM +0100, Brad Bowman wrote:
> How can you match a literal "#" in a rule?
>  \# or only \x{23}?
> S05 seems clear "# now always introduces a comment",
> and \# is not listed in the escapes.
> But then Perl 5 has \# so I assume it's just an omission...

Short answer:  \# matches a literal '#'.  (So does <'#'>.)

Longer answer:  I think "always" may be too strongly worded
in S05, it's not meant as an absolute but rather it's contrasting
perl 6 expressions from perl 5 ones (as part of the "because /x
is default" above).  

For example, a few lines earlier S05 says that "^ and $ now 
always match the start/end of a string", but the "always" here 
is mean to distinguish perl 6 from perl 5, where ^ and $ could 
have different meanings depending on the /m option.  Similarly,
in perl 5 a '#' could have different meanings depending on the /x
option, but in perl 6 it is always a metacharacter and introduces
a comment.  To get a literal # you can escape it with a backslash.


Reply via email to