in reply to Hash of hashes: Check if the element is present in previous hash table
Do you really need a HoH for this? I'm thinking a hash will suffice. Maybe something like this:
my %hash = (); foreach my $file (qw/File1 File2 File3 File4/) { my %unique_in_file = (); open(IN, '<', $file); while (<IN>) { chomp; $hash{$_}++ unless $unique_in_file{$_}; $unique_in_file{$_} = 1; } close(IN); } use Data::Dumper; print Dumper(grep { $hash{$_} == 4 } keys %hash);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Hash of hashes: Check if the element is present in previous hash table
by snape (Pilgrim) on Apr 03, 2012 at 23:59 UTC |
In Section
Seekers of Perl Wisdom