Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: "ee" in Regular Expression: version issue?

by kennethk (Abbot)
on Dec 03, 2012 at 20:23 UTC ( #1006945=note: print w/ replies, xml ) Need Help??


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.


Comment on Re^2: "ee" in Regular Expression: version issue?
Select or Download Code
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006945]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (12)
As of 2015-07-02 10:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (34 votes), past polls