Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: need help in editing multiple word in a file

by pvaldes (Chaplain)
on Nov 20, 2012 at 12:43 UTC ( #1004704=note: print w/ replies, xml ) Need Help??


in reply to need help in editing multiple word in a file

I need to match cat and replace brave with frightened

while (<DATA>){ next unless /\bcat\b/i; s/brave/frigthened/; print $_; } __DATA__ My Cat is brave but ocicat is also brave and dog is brave catwoman wonderbrave

You can achieve similar results using grep


Comment on Re: need help in editing multiple word in a file
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (16)
As of 2015-07-31 17: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 (279 votes), past polls