rv799cv has asked for the wisdom of the Perl Monks concerning the following question:
Hello All,
Gabor Azabo re-directed me to this site and I hope someone can give me a guide and clue.
I have wrote a Perl script to update about 1200 files for searching and replacing.
I have used a array of hashes like my
@myHashArray = ( {toFind => '<Image Name="Logo"> <Source>Embedded</Sou +rce>', toReplace => '<Image Name="Logo"><Source>E +xternal</Source>' }); Then I use this statement to find and replace the file. $data =~ s/$_->{toFind}/$_->{toReplace}/g foreach (@myHashArray);
Everything is working great and I am creating a log file (name of files I have changed) but I like also to get the values I have changed in that document. I want to get the value of /$_->{toFind}/ and toReplace in a log file too. Currently my log file is something like:
01- FirstFile.xml
02- SecondFile.xml
But want to have something like
01- FirstFile.xml
a. Original line: <Image
Name="Logo"><Source>Embedded</Source>
b. Replace with: <Image Name="Logo"><Source>External</Source>
And so on...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: array of hashes help
by rjt (Curate) on Apr 23, 2014 at 21:13 UTC | |
by rv799cv (Initiate) on Apr 23, 2014 at 21:48 UTC | |
by rjt (Curate) on Apr 23, 2014 at 22:23 UTC | |
by rv799cv (Initiate) on Apr 23, 2014 at 23:04 UTC | |
|
Re: array of hashes help
by Fessenden (Initiate) on Apr 23, 2014 at 23:23 UTC |