bject: Re: anonymous hash reference
>>>>> "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" == 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;
}
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;
}
What