in reply to hash of arrays of arrays
Here is a code similiar to your problem that prints the duplicates.
Output:#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %duplicates; my $serials = [ [qw/ foo bar serial1 /], [qw/ who now serial2 /], [qw/ one more serial2 /], [qw/ two end serial3 /] ]; for my $row (@$serials) { my $clean = $row->[2]; push @{$duplicates{$clean}}, $row; } print Dumper \%duplicates; for my $clean (keys %duplicates) { my $aref = $duplicates{$clean}; if (@$aref > 1) { # if duplicates for my $row (@$aref) { print "@$row\n"; } } }
ChrisC:\Old_Data\perlp>perl t7.pl $VAR1 = { 'serial3' => [ [ 'two', 'end', 'serial3' ] ], 'serial1' => [ [ 'foo', 'bar', 'serial1' ] ], 'serial2' => [ [ 'who', 'now', 'serial2' ], [ 'one', 'more', 'serial2' ] ] }; who now serial2 one more serial2
Update: Don't know why I pulled $clean out. This version doesn't.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: hash of arrays of arrays
by tnyflmngs (Acolyte) on Aug 24, 2012 at 02:21 UTC | |
by Marshall (Canon) on Aug 24, 2012 at 11:41 UTC |