Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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 browsing the Monastery: (4)
As of 2014-08-01 05:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (256 votes), past polls