in reply to Regex Grumblings (Variable Interpolation)
A regex reads a '$' as the end of the string or a variable to interpolate. However, with $foo you just get the literal ($,b,a,r) back, no matter if you use \Q or not. So:
Just prints one 'bar'. Take a look at perlre and perlop.$_='Some string with $foo and bar'; $bar='bar'; $foo='$bar'; /$bar/ and print "$&\n"; /$foo/ and print "$&\n"; /\Q$foo\E/ and print "$\n";
Cheers,
Jeroen
"We are not alone"(FZ)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex Grumblings (Variable Interpolation)
by tadman (Prior) on May 23, 2001 at 15:26 UTC | |
by Corion (Patriarch) on May 23, 2001 at 15:35 UTC | |
by tadman (Prior) on May 23, 2001 at 17:42 UTC | |
by Anonymous Monk on May 23, 2001 at 21:22 UTC | |
by jeroenes (Priest) on May 23, 2001 at 15:35 UTC | |
by grinder (Bishop) on May 23, 2001 at 16:15 UTC | |
by larryk (Friar) on May 23, 2001 at 16:17 UTC |