Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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 meditating upon the Monastery: (12)
As of 2014-09-22 16:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (198 votes), past polls