http://www.perlmonks.org?node_id=1006945


in reply to Re: "ee" in Regular Expression: version issue?
in thread "ee" in Regular Expression: version issue?

Or use straight interpolation: my $rhs = '"$1$2$3"';. The key here is that the string literal present after the initial eval (which subs $rhs to its value) is valid Perl code.


#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Replies are listed 'Best First'.
Re^3: "ee" in Regular Expression: version issue?
by Kenosis (Priest) on Dec 03, 2012 at 20:32 UTC

    Yes, excellent. Perhaps the enclosing double-quotes (also) helps to disambiguate the expression. After the first eval, the interpreter sees this:

    $var =~ s/(\d*?)-(.*?)-(.*)/$1$2$3/ee;

    The substituting expression is problematic w/o either being interpolated via "$1$2$3" or concatenated using $1.$2.$3.