[Purdue-pm] Perl 6 regexes are different

Mark Senn mark at purdue.edu
Wed May 4 08:56:59 PDT 2011


While debugging a chunk of code in Perl 6 (P6), I forgot about how P6
regexes work differently than in Perl 5 (P5) and suspected the problem
wasn't with regexes anyway.  I was wrong.

P6 automatically ignores spaces in regexes.  So in P6 the regex
/two words/ is equivalent to /twowords/ in P6 or /two words/x
in P5.  To make spaces significant in P6 regexes do, for example,
    m:sigspace/two words/
or,
    m:s/two words/
for short.

The "m" is short for "match".  The "s" is short for "sigspace"---sigspace
means spaces in the regex are significant.

Just another one of the things our fingers know how to do in P5
that we'll need to engage our brains to do in P6.

Touch your right index finger against the top of your head, your left
index finger against the top of your foot, and say "regex"---it will
help you remember this message.

-mark


More information about the Purdue-pm mailing list