Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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: (6)
As of 2015-07-29 02:50 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 (260 votes), past polls