Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
No such thing as a small change
 
PerlMonks  

Re: Hash of hashes: Check if the element is present in previous hash table

by Riales (Hermit)
on Apr 03, 2012 at 23:45 UTC ( #963336=note: print w/ replies, xml ) Need Help??


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
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 !!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://963336]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2014-04-18 04:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (461 votes), past polls