|Pathologically Eclectic Rubbish Lister|
iterating hash keys?by R56 (Sexton)
|on Sep 26, 2013 at 14:41 UTC||Need Help??|
R56 has asked for the
wisdom of the Perl Monks concerning the following question:
Hey all! I'm starting to learn Perl to help me on my job and I stumbled across a problem that I can't seem to solve.
First, I have a list of names that have an ID associated, like:
Then, i have a list of those names, that need to be replaced with the associated ID.
My first tought was to put the 'name-id' data in a hash, since every name only has one ID, and they are all unique values.
I would then push the 'names to be replaced' file into an array, and iterate through all the hash keys, while looping the array, matching each key and replacing it with its value.
Sounded like a good ideia, but can't seem to iterate and replace both things effectively.
Maybe I'm overcomplicating a simple problem, but can you guys point me in the right direction?
Thanks in advance!