in reply to Regex delimiter

For one thing, when you use non-standard delimiters, you need to preface them with "m". In other words, you can use /regex/ or m/regex/, or m#regex#, but you cannot use #regex# without the leading m.

Also, in perlop, you can read the following explanation as to what characters are permissible:

If "/" is the delimiter then the initial m is optional. With the m you can use any pair of non-alphanumeric, non-whitespace characters as delimiters. This is particularly useful for matching path names that contain "/", to avoid LTS (leaning toothpick syndrome). If "?" is the delimiter, then the match-only-once rule of ?PATTERN? applies. If "'" is the delimiter, no interpolation is performed on the PATTERN.

So to reiterate: In your example you're using 'a' as the delimiter. This is not allowed according to perlop. The documentation explains that the delimiter must be non-alphanumeric, and non-whitespace.


Dave

Replies are listed 'Best First'.
Re^2: Regex delimiter
by jwkrahn (Abbot) on Jun 26, 2007 at 20:17 UTC
    The documentation is wrong in this case, you can use alphanumeric delimiters:
    $ perl -le'$_ = q[bcdefg]; print $1 if m x..(..)..x;' de $ perl -le'$_ = q[bcdefg]; print $1 if m 7..(..)..7;' de

      The documentation and reality are at odds with each other, it seems. However, I think there's probably some wisdom in sticking with documented behavior for code that needs to be robust, until the behavior that defies documentation is reconciled. You never know which way the pendulum will swing when they sort it out.


      Dave