in reply to Looping through an Array of Hashes

is there a way to get it to work WITH the %m temp vars? for the life of me, i can't figure this out -- and it would save me a bunch of lines in a db pull i've got (i'm pulling the fields into a hash, stored in an array)

Replies are listed 'Best First'.
Re^2: Looping through an Array of Hashes
by xorl (Deacon) on Jun 15, 2006 at 16:13 UTC
    I realize this is way too late to help this anon monk, but in case someone finds via search here's how you can do it with the temp hash...
    #!/usr/bin/perl use strict; use warnings; my %hash1 = ("a" => "Apple", "b" => "Ball"); my %hash2 = ("c" => "Cat", "d" => "Dog"); my @myarray; push @myarray, \%hash1; push @myarray, \%hash2; foreach my $value (@myarray) { foreach my $hvalue (keys %{$value}) { print $hvalue . "\t"; print $value->{$hvalue} . "\n"; } }