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

Re^3: Efficient way to replace a set of values with another set of values

by tobyink (Abbot)
on Nov 23, 2012 at 10:50 UTC ( #1005248=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Efficient way to replace a set of values with another set of values
in thread Efficient way to replace a set of values with another set of values

Indeed. I was in two minds about whether to include it or not. The substitutions in the examples were consistently at the start of lines, but the OP never explicitly specified that that would always be the case, so I decided to go for the more general "anywhere in the string" match.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


Comment on Re^3: Efficient way to replace a set of values with another set of values
Re^4: Efficient way to replace a set of values with another set of values
by ColonelPanic (Friar) on Nov 23, 2012 at 11:04 UTC
    Yeah, I agree that it depends on exact requirements. I thought it was worth mentioning though, because it's such a simple pattern that I would be worried about it popping up elsewhere in the data.


    When's the last time you used duct tape on a duct? --Larry Wall

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005248]
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 2014-12-26 13:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (171 votes), past polls