--- Daniel Falkenberg <[EMAIL PROTECTED]> wrote: > Hello All, > > I am still having trouble printing out a second lot of hash keys in a > hash of a hash. Here is what I have so far. Any ideas or suggestions > will be greatly appriciated... > > %users = ( > 'user1' => { > 'Fullname1' => 'YES' > }, > 'user2' => { > 'Fullname2' => 'NO' > }, > 'user3' => { > 'Fullname3' => 'YES' > } > ); > > Now when I do the following... > > foreach $username (keys %users) { > print $users{$username}; > }
Dan, You just need another foreach loop that prints the keys of the hashref that you are at. Here is some sample syntax: use strict; my %users = ( 'user1' => { 'Fullname1' => 'YES' }, 'user2' => { 'Fullname2' => 'NO' }, 'user3' => { 'Fullname3' => 'YES' } ); foreach my $user (keys %users) { foreach my $name (keys %{ $users{$user} } ) { print $users{$user}{$name},"\n"; } } Note how I wrap $users{$name} in %{...} to tell Perl that I am using a hash ref here. Cheers, Curtis "Ovid" Poe ===== "Ovid" on http://www.perlmonks.org/ Someone asked me how to count to 10 in Perl: push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//; shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A __________________________________________________ Do You Yahoo!? Check out Yahoo! Shopping and Yahoo! Auctions for all of your unique holiday gifts! Buy at http://shopping.yahoo.com or bid at http://auctions.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]