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:
bananas 456
oranges 23
peaches 897236
kiwis 3726
(...)
Then, i have a list of those names, that need to be replaced with the associated ID.
bananas,oranges
peaches,peaches,peaches
kiwis
oranges
kiwis,oranges,bananas,bananas
(...)
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!
-R
In reply to iterating hash keys? by R56
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |