Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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 drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2014-07-11 10:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (224 votes), past polls