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


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

>I want to replace some words in a file

ok

>In words are present in whole file. But starting of each line in file is by different word so i am using a file in which first character of line at which i wanna do replacement is written

mmmh? I wonder how you could have a file with unwritten characters. Do you want to match only the first character?

>and along with it replaced word is given ( i name it match file)

uh?

sorry, I get lost, can't understand what you want to do exactly

Could we have a small example with some data

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

Replies are listed 'Best First'.
Re^2: need help in editing multiple word in a file
by vkp (Novice) on Nov 19, 2012 at 17:40 UTC

    consider this example: lion is brave animal. cat is brave animal. dog is brave animal. in this i want to change brave by frightened only for cat. so i need to match cat and replace brave with frightened. So match file is like: cat frightened . Thanks.

      Ok, so how do you propose deciding which word in the string:

      cat is brave animal

      should be replaced by 'frightened'?

      In other words, is this also acceptable:

      cat frightened brave animal

      ?

      Update: de-gobbledegooked, I hope...