![]() |
|
"be consistent" | |
PerlMonks |
Re^2: hash and array mismatchby TGI (Parson) |
on May 10, 2007 at 17:31 UTC ( #614711=note: print w/replies, xml ) | Need Help?? |
I assume your snippet is intended to go inside the OP's for loop:
After I tweaked your code to work with the OP's code, there are still problems. You have a unnecessary nested loop that will grow with each pass through the outer loop. Also, if a key shows up three or more times, the last value will overwrite the value stored for the second key. I've fixed these issues below.
Even after its been fixed, I still wouldn't use this approach. I'd store repeated values in arrays as other posters have suggested.
In Section
Seekers of Perl Wisdom
|
|