in reply to Re^5: reg. expr. multiple substitutions
in thread reg. expr. multiple substitutions
whatever escapaing might be required had you not used qr//, would still be requiredNot completely. First off, if a regex $r is used as the *only* part of a pattern in /$r/ or s/$r/../, then it is not interpolated, but used as is. Secondly, by using a regex literal rather than a string literal, you get backslashed things handled right:
(Although this is mostly moot, since as was pointed out elsewhere, hash keys are stored as strings.)$r = qr/\bfoo/; /$r/; # matches word boundary $r = "\bfoo"; /$r/; # matches backspace
Dave.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: reg. expr. multiple substitutions
by BrowserUk (Patriarch) on May 17, 2012 at 16:06 UTC |