Now, you can either save the output to a file, and use other tools (or write other perl code) to do interesting things with the list, or just add some more steps in the above script, to grep for values of interest in the %distro hash -- e.g.:use strict; # pretend these are our four arrays: my @A = qw/we me you them us foo others folks/; my @B = qw/them I we he she it one foo/; my @C = qw/foo bar baz blah me he we she/; my @D = qw/this that another foo bar baz/; my %arefs = ( A => \@A, B => \@B, C => \@C, D => \@D ); my %distro; for my $ary ( sort keys %arefs ) { my $aref = $arefs{$ary}; for ( my $i=0; $i<@$aref; $i++ ) { my $elem = $$aref[$i]; $distro{$elem} .= sprintf( " %s%3.3d ", $ary, $i ); } } for my $elem ( sort keys %distro ) { print "$elem\t$distro{$elem}\n"; } __OUTPUT__ I B001 another D002 bar C001 D004 baz C002 D005 blah C003 folks A007 foo A005 B007 C000 D003 he B003 C005 it B005 me A001 C004 one B006 others A006 she B004 C007 that D001 them A003 B000 this D000 us A004 we A000 B002 C006 you A002
my @keylist = sort keys %distro; my @hitAll4 = grep { $distro{$_} =~ /A\d+ B\d+ C\d+ D\d+/ } @keylist; my @missingD = grep { $distro{$_} !~ / D\d+/ } @keylist; # and so on.
(updated the print statement to use tabs for nicer alignment)
In reply to Re: confusing array comparison
by graff
in thread confusing array comparison
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |