Hi Raphael!

On Thursday 25 Feb 2010 12:59:33 raphael() wrote:
> My BAD :(
> 
> THERE IS NO FIRST ELEMENT IN A HASH!!
> 
> PLEASE FORGIVE ME.  I AM IN A THICK OF EVERYTHING TODAY.
> 
> LET ME REPHRASE --
> HOW DO I LOOP OVER THE ANONYMOUS HASH WHICH IS INSIDE AN ARRAY?

OK, no need to use all-caps (it's considered akin to shouting in netiquette.). 
You can use textual *bold* or /italics/ or _underline_ or whatever to 
highlight.

Regarding your question here is an example (tested):

«
#!/usr/bin/perl

use strict;
use warnings;

my @array_of_hashes =
(
    {
        first => "Bart",
        last => "Simpson",
        city => "Springfield",
    },
    {
        first => "Sherlock",
        last => "Holmes",
        city => "London",
    },
    {
        first => "Socrates",
        last => "None",
        city => "Athens",
    },
);

foreach my $record (@array_of_hashes)
{
    foreach my $key (keys(%$record))
    {
        my $value = $record->{$key};
        print "$key ==> $value\n";
    }
}
»

This prints:

<<<
city ==> Springfield
first ==> Bart
last ==> Simpson
city ==> London
first ==> Sherlock
last ==> Holmes
city ==> Athens
first ==> Socrates
last ==> None
>>>

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Parody on "The Fountainhead" - http://shlom.in/towtf

Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to