Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: regexp wizardry needed

by Corion (Pope)
on Jan 25, 2013 at 17:13 UTC ( #1015376=note: print w/ replies, xml ) Need Help??


in reply to Re: regexp wizardry needed
in thread regexp wizardry needed

perlop says that /r is for non-destructive operation of a regular expression. You can simply replace that by introducing a temporary variable:

my $result = $example =~ s/foo/bar/r;

... can be replaced by

(my $result=$example) =~ s/foo/bar/;

In your case, you will have to make sure your map block actually returns the intended value:

... map { (my $result=$_) =~ s/foo/bar/; $result } @elements


Comment on Re^2: regexp wizardry needed
Select or Download Code
Replies are listed 'Best First'.
Re^3: regexp wizardry needed
by Anonymous Monk on Jan 25, 2013 at 18:03 UTC
    /r is only availabe in 5.14 I am using 5.10.

      Please read Corion's reply: "In your case, you will have to..."

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2015-07-31 23:59 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 (285 votes), past polls