more useful options | |
PerlMonks |
comparing contents of two arrays and output differencesby PitifulProgrammer (Acolyte) |
on Jan 02, 2015 at 10:53 UTC ( [id://1111985]=perlquestion: print w/replies, xml ) | Need Help?? |
PitifulProgrammer has asked for the wisdom of the Perl Monks concerning the following question:
Dear Perlmonks,
first off, happy new year to all of you. What better way to start a new year than with a perl question. I am still a noob, not having had many chances to dig deeper into coding in the last months. The issue is as follows: After running a piece of code that finds particular files and replaces some characters if need be, the output folder contains the original files and backup files marked by .bak. Previously, it was sufficient to compare the files manually using a diff tool. I also used the UNIX diff if there were more than a few files to check. Recently, the number of folders and files has increased and I would like the comparison to be script-based, too. The trouble is that I cannot find a starting point. I have been toying with modules such as Array::Diff and Array::Compare, but the output was always a hash reference not a report ( at least I think it was a hash reference ). I also tried out Text::Diff leading to the same result To put it in a nutshell: Given two arrays in a given folder, e.g.:
I would like to compare file_01.xml with file_01.xml.bak and so on. I was considering of maybe creating a hash but refrained from doing so since, as far as I have been told, hash items are unordered. I am even not sure by now if separating the files into 2 arrays is a wise move. Could somebody please give me a hint about how to approach this problem? Please find my endeavours below, some of which have already been posted here in the forum and I would also like to thank those people. I am just adding these snippets, just in case I missed a convenient approach already. Personally, the main difficulty is to think of a solution how to make sure that file_01.xml is compared with file_01.xml.bak and the moving on to the next and selecting the right data structure for doing so. Thanks in advance for your suggestions Kind regards C.
Back to
Seekers of Perl Wisdom
|
|