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 contemplating the Monastery: (5)
As of 2014-12-25 08:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls