Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Parsing text file into a hash with multiple values per key

by Anonymous Monk
on Oct 03, 2012 at 22:40 UTC ( #997142=note: print w/ replies, xml ) Need Help??


in reply to Parsing text file into a hash with multiple values per key

how do I remove duplicates (Host and VM)?

There are no duplicate hosts (hash takes care of that), so to get rid of duplicate VM, use another hash, a hash of hashes, ie  $HostVM{$host}{$VM}++

how do I then count the # of values per key?

For your existing code  my $count = @{ $hash{ $host } };

For my code  my $count = keys %{ $hash{$host}{$vms} };

TutorialsData Types and Variables


Comment on Re: Parsing text file into a hash with multiple values per key
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2015-07-31 03:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls