in reply to Re^5: Is there better way to delete dups in an AoH?
in thread Is there better way to delete dups in an AoH?
page=>'fall', chap=>'fall'BUT, what if they are different:
Which prints:my $AoH = [ { page => 'main', chap => 'About'}, { page => 'main', chap => 'Contact'}, { page => 'main', chap => 'About'}, { page => 'sub', chap => 'About'}, { page => 'sub', chap => 'Contact'} ]; my %uniq = map { ($_->{page} => 1, $_->{chap} => 1) } @$AoH; @$AoH = map { { page => $_ , chap=>$_ } } keys %uniq; print Dumper ($AoH);
I want to end up with:$VAR1 = [ { 'chap' => 'Contact', 'page' => 'Contact' }, { 'chap' => 'About', 'page' => 'About' }, { 'chap' => 'sub', 'page' => 'sub' }, { 'chap' => 'main', 'page' => 'main' } ];
eliminating that dupe element of:$VAR1 = [ { 'page' => 'main', 'chap' => 'About' }, { 'page' => 'main', 'chap' => 'Contact' }, { 'page' => 'sub', 'chap' => 'About' }, { 'page' => 'sub', 'chap' => 'Contact' } ];
I've stared at it for an hour and am bewildered. Ideas? Thanks.'page' => 'main', 'chap' => 'About'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Is there better way to delete dups in an AoH?
by Roy Johnson (Monsignor) on Jun 08, 2004 at 03:32 UTC | |
by bradcathey (Prior) on Jun 08, 2004 at 11:03 UTC |