bradcathey has asked for the wisdom of the Perl Monks concerning the following question:
Fellow Monasterians,
I had no problem grepping a straight AoH, but I can't figure out how to do it with references. Googled and Supersearched to little avail (learned lots of other stuff, though ;^). What am I not getting?
my $AoHref = [ { name => "barney", age => "43" }, { name => "fred", age => "44" }, { name => "wilma", age => "42" } ]; my $newAoH = grep { !($_->{'name'} eq "fred") } $AoHref; print Dumper ($newAoH);
I'm sure the problem is in how I dereference in the grep statement. Tried things like:
my $newAoH = grep { !({$_->{'name'}} eq "fred") } $AoHref;
...but nada. Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Grep and AoH references
by davido (Cardinal) on Dec 30, 2004 at 16:43 UTC | |
by bradcathey (Prior) on Dec 30, 2004 at 16:52 UTC | |
|
Re: Grep and AoH references
by Roy Johnson (Monsignor) on Dec 30, 2004 at 16:42 UTC | |
by de-merphq (Beadle) on Dec 30, 2004 at 16:49 UTC | |
by bradcathey (Prior) on Dec 30, 2004 at 16:50 UTC | |
|
Re: Grep and AoH references
by trammell (Priest) on Dec 30, 2004 at 17:04 UTC |