http://www.perlmonks.org?node_id=963336


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);
  • Comment on Re: Hash of hashes: Check if the element is present in previous hash table
  • Download Code

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

    Hi Riales,

    Thanks for the reply. I am interested to know how can traverse with the elements when there is HoH since i need to the certain operation. Thanks again !!