in reply to Re: Regex stored in a scalar
in thread Regex stored in a scalar
$_ = 'foo'; $left = '(.)(.)'; $right = '$1$2$2$1'; s{$left}{"qq{$right}"}ee; print "$_\n"; s{$left}{eval "qq{$right}"}e; print "$_\n"; __END__ foofo foofofo
first /e turns "" into a string qq{$1$2$2$1}
second /e interpolates qq{$1$2$2$1} at the correct time and substitutes into the original string
string eval is eval so arbitrary code could be executed
So, to make it safer, instead of eval ... use some form of String::Interpolate/String::Interpolate::RE
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Regex stored in a scalar ( s///eeval )
by Athanasius (Archbishop) on Aug 23, 2015 at 03:52 UTC |