Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Counting Variations of Key in a Hash

by davidrw (Prior)
on Aug 09, 2005 at 15:29 UTC ( [id://482250]=note: print w/replies, xml ) Need Help??


in reply to Counting Variations of Key in a Hash

So the end result for HIPPO1 and HIPPO2 should be the same, right? Assuming that, the following ends up with HIPPO as a key (no number -- just the 'root' name) (note that hashing on the 'root' animal name also eliminates the need for the nested looping over bigHash):
my %animals; while( my ($state, $zoos) = each %bighash ){ while( my ($zoo, $row) = each %$zoos ){ my $animal = $row->[1]; $animal =~ s/\d+$//; push @{$animals{$animal}->{$state}}, $zoo; } }
Note in your original code that @zoos probably shouldn't be globally scoped.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-03-28 11:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found