Thanks Uri and Jepp,
that was exactly the information I was looking for.
- Original Message -
From: "Uri Guttman"
To: "Jeff Pang"
Cc: beginners@perl.org
Sent: Sunday, October 31, 2010 6:39:50 PM GMT +01:00 Amsterdam / Berlin / Bern
/ Rome / Stockholm / Vienna
Su
> "JP" == Jeff Pang writes:
JP> print check_for_exists('name','foo');
JP> sub check_for_exists {
JP>my $key = shift;
JP>my $value = shift;
JP> for my $item (@$foo) {
JP> if ($item->{$key} eq $value ) {
JP>return 1;
JP> }
JP> }
δΊ 2010-10-31 21:43, Thorsten Scherf ει:
Hi,
I have an array with anonymous hash references like the following:
$foo = [ {
name = value,
id = value,
},
{
name = value,
id = value,
}
];
Iterating through the hash references works with:
foreach $item (@$foo) {
do something with $item->name;
}