in reply to Trying to remove duplicate rows using hashes
When you output, you use the value of $k2 as a hash reference, but the second time through the inner loop, its value has been replaced by the key that each returned on the first time through. You need something more like this:
while ( my ($k1, $href) = each %hash ) { while ( my ($k2, $k3) = each %{ $href } ) { } }
Incidentally, you use English without the important -no_match_vars option, and you use warnings as well as giving the -w, which is a bit redundant.
Also, your sample output is in the order that the lines were received, but you won't get your output in that order if you're using each and hashes for storage. There are ways of coping with that, but I can't tell if that's one of your requirements or not.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Trying to remove duplicate rows using hashes
by Angharad (Pilgrim) on Oct 21, 2008 at 15:55 UTC | |
by kyle (Abbot) on Oct 21, 2008 at 15:58 UTC |