in reply to Regular expression "replace string interpolation" problem
Or you might want to write it like this:... my $replace = '"$1 Perl"'; $text2 =~ s/$match/$replace/ee;
Probably even a better solution would be write $replace as a subroutine:my $replace = '$1 Perl'; # use original setting of $replace $text2 =~ s/$match/'"'.$replace.'"'/ee;
and then only level of evaluation is needed.my $replace = sub { "$1 Perl" }; $text2 =~ s/$match/$replace->()/e;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regular expression "replace string interpolation" problem
by cLive ;-) (Prior) on May 16, 2008 at 22:25 UTC | |
by ikegami (Patriarch) on May 16, 2008 at 22:39 UTC | |
by pc88mxer (Vicar) on May 17, 2008 at 06:36 UTC |