in reply to regular expression problem
Here is one solution:
$string =~ s/$regex/eval "\"$replace\""/e;
The problem with your method was that to get that to work it would have to do variable substitution twice, first to substitute $replace with '$2 $1', then a second variable substitution of $2 and $1. Using eval in connection with the e modifier basically does just this second variable substitution.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regular expression problem
by johngg (Canon) on Aug 17, 2009 at 12:44 UTC | |
|
Re^2: regular expression problem
by perl_fan (Novice) on Aug 17, 2009 at 12:13 UTC |