Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://963336]
help
Chatterbox?
[thezip]: I currently don't have access to CYGWIN, else I'd just do a tail -f on the logfile.
[Corion]: thezip: If you want to open vim and can live with opening a second console window, use start "The results" vim.exe c:\path\to\logfile .log
[thezip]: Ooops... I lied. I guess Cygwin is back. I'll just do a tail -f instead. Better. Sorry for the noise.

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (13)
As of 2017-03-27 18:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (321 votes). Check out past polls.