rmexico has asked for the wisdom of the Perl Monks concerning the following question:
is there an easy way to tell if @PEOPLE contains a person named "John" w/o looping over the array and extracting each hash then comparing. The following works, but seems long-winded to me:while (blah) { ## do something %person = ('fname => $fname, 'lname' => $lname); push @PEOPLE, \%person; }
easier way?foreach my $ppl (@PEOPLE) { my $fname = $ppl->{'fname'}; .... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: easy way to extract a hash from an array?
by davido (Cardinal) on Feb 08, 2006 at 16:53 UTC | |
|
Re: easy way to extract a hash from an array?
by nobull (Friar) on Feb 08, 2006 at 18:20 UTC | |
|
Re: easy way to extract a hash from an array?
by MCS (Monk) on Feb 08, 2006 at 17:15 UTC | |
|
Re: easy way to extract a hash from an array?
by beachbum (Beadle) on Feb 08, 2006 at 18:47 UTC | |
|
Re: easy way to extract a hash from an array?
by johngg (Canon) on Feb 09, 2006 at 10:28 UTC |