Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2016-10-22 03:07 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (291 votes). Check out past polls.