Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Combining multiple =~ s/

by LanX (Saint)
on Mar 07, 2021 at 20:50 UTC ( [id://11129296]=note: print w/replies, xml ) Need Help??


in reply to Combining multiple =~ s/

the exact translation is in a loop

DB<1> @a= qw/zero one two three four/ DB<2> $pi ='three . one four one' DB<3> $pi =~ s/$a[$_]/$_/ig for 0..4 DB<4> p $pi 3 . 1 4 1 DB<5>

Please note that replacing all the "one" before replacing "two" might change the input in unexpected ways.

It really depends if you are really replacing numbers ...

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-24 04:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found