http://www.perlmonks.org?node_id=1004704


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