Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: How to iterate through a hash of hashes?

by elwarren (Curate)
on Jan 11, 2005 at 20:08 UTC ( #421401=note: print w/ replies, xml ) Need Help??


in reply to How to iterate through a hash of hashes?

Just to be different, save a step and use each:

#!/usr/bin/perl use warnings; use strict; my %hash = (); $hash{"192.168.0.1"}{"randy"} = "thomas"; $hash{"192.168.0.1"}{"ken"} = "samual"; $hash{"192.168.0.2"}{"jessie"} = "jessica"; $hash{"192.168.0.2"}{"terry"} = "ryan"; foreach my $ip (keys %hash) { while (my ($key, $value) = each %{ $hash{$ip} } ) { print "$key = $value \n"; } }


Comment on Re: How to iterate through a hash of hashes?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2014-12-20 16:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (96 votes), past polls