Next | Regular Expression Mastery | 72 |
/x lets you write regexes more readably.
White space is ignored. (Use \s)
#-style comments are allowed
Extended and very practical example coming up later...
Caution: Unescaped / will still terminate the regex, even if it's in a comment!
$x =~ /\d+ # numerator $FRAC # FRAC matches either a / or a : symbol \d+ # denominator /x;
Perl sees the / in the 'comment' before it sees the /x
It thinks that the / ends the regex
Confusion ensues
Perl 6 will fix this: modifiers precede the pattern instead of following it
Next | Copyright © 2002 M. J. Dominus |