No such thing as a small change | |
PerlMonks |
Re: Perl logic request for an IO scenarioby Athanasius (Archbishop) |
on Apr 12, 2015 at 04:46 UTC ( [id://1123172]=note: print w/replies, xml ) | Need Help?? |
Hello Apronline, In Perl, the usual way to handle this sort of lookup task is with a hash. As the hash data resides in memory, the hash should be populated with data from the smaller of the two files. In this case, it appears that File2 is the shorter, so you should begin by building a hash from File2 with key/value pairs of the form: 1 => 'Generic user error'. Once you have this hash (i.e., lookup table), it is a straightforward task to go through the data in File1, line by line, extract the code element, and look it up in the hash using the exists function.
Output:
Hope that helps,
In Section
Seekers of Perl Wisdom
|
|