Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: need help in editing multiple word in a file

by pvaldes (Chaplain)
on Nov 18, 2012 at 21:12 UTC ( #1004460=note: print w/replies, xml ) Need Help??

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

>I want to replace some words in a file


>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)


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...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1004460]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2018-06-18 04:38 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (107 votes). Check out past polls.