
rovf
Veteran
Jan 24, 2012, 9:23 AM
Post #2 of 3
(9028 views)
|
Re: [jtra00] I Need to replace names from 1 file everytime they occur in another file
[In reply to]
|
Can't Post
|
|
Replacement itself is easiest by substitution via regular expression. For example, if $s equals 'abc_3 X Y Z', the statement changes $s into 'abc_dogfood X Y Z'. To extract the values you need, from file A, you read it line by line, and use the split function. The canonical way to store the association between the numbers (2) and keywords (rat) would be to use a hash. Since in your case, the numbers are continuous integers, you could also use an array, depending on what you feel more comfortable with.
|