in reply to Listing Keys in a specific element(s) in an array of hashs

My self-taught way was this, which means maybe others have better style...

for ( my $i=0; $i<=$#data; $i++ ) { my $href = $data[$i]; for ( keys %$href ) { print "$_\n"; } }

-S

Replies are listed 'Best First'.
Re^2: Listing Keys in a specific element(s) in an array of hashs
by mrborisguy (Hermit) on Jun 20, 2005 at 13:15 UTC

    Most monks would suggest the more natural foreach for something like this, as it tends to cut down on "one-off" errors. Also, it tends to be more intuitive (at least after you've learned Perl; I can see how your way would be more intutitive to a person coming from C or Java).

    foreach my $href ( @data ) { for ( keys %$href ) { print "$_\n"; } }

        -Bryan