bonoboy has asked for the wisdom of the Perl Monks concerning the following question:
Pretty newbie, so I'm sure you can all answer this :)
I want to run a foreach on all the elements of all the hashes nested within a hash. Just now, however, I'm having difficulty accessing them.
Here's the code, and you'll see the bit that's going wrong. Help!
#!/usr/bin/perl -w my %termservers = ( TERM192_168_0_1 => { CE_36xx101 => "PORT_2047", CE_36xx122 => "PORT_2060", CE_36xx124 => "PORT_2062" }, TERM192_168_0_2 => { CE_26xx103 => "PORT_2012", CE_26xx109 => "PORT_2014" } ); foreach my $key (keys %termservers) { print "1 $key \n"; #works# print "2 $termservers{$key}\n"; #prints hash_ref# print "3", keys({%termservers{$key}}), "\n"; #doesn't work# };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash of hashes question
by ChrisR (Hermit) on Oct 22, 2003 at 15:30 UTC | |
by Enlil (Parson) on Oct 22, 2003 at 16:09 UTC | |
by Aragorn (Curate) on Oct 23, 2003 at 07:34 UTC | |
|
Re: Hash of hashes question
by etcshadow (Priest) on Oct 22, 2003 at 15:31 UTC | |
by ChrisR (Hermit) on Oct 22, 2003 at 15:39 UTC | |
by hmerrill (Friar) on Oct 22, 2003 at 16:47 UTC | |
by etcshadow (Priest) on Oct 22, 2003 at 17:25 UTC | |
by hmerrill (Friar) on Oct 22, 2003 at 21:02 UTC | |
by etcshadow (Priest) on Oct 23, 2003 at 03:11 UTC | |
|
Re: Hash of hashes question
by Beechbone (Friar) on Oct 22, 2003 at 21:30 UTC | |
|
Re: Hash of hashes question
by Anonymous Monk on Oct 22, 2003 at 19:02 UTC | |
|
Re: Hash of hashes question
by Roger (Parson) on Oct 23, 2003 at 02:39 UTC |