Rather than use eval inside the replacement term you can use a double ee modifier (see the s operator in Regexp Quote Like Operators).
$ perl -le ' > $str = q{10 09}; > $reg = q{(\d+) (\d+)}; > $rep = q{"$2 $1"}; > $str =~ s/$reg/$rep/ee; > print $str;' 09 10 $
I hope this is of interest.
Cheers,
JohnGG
In reply to Re^2: regular expression problem
by johngg
in thread regular expression problem
by perl_fan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |