>>>>> "JP" == Jeff Pang <[email protected]> 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> }
JP> return 0;
JP> }
that reduces to just:
$item->{'foo'} eq $value ;
there is no reason for a full sub for that. and it has a flaw (as does
the OP's question). which comparison op do you use? hash values can be
numbers too so eq may not work as expected on them.
uri
--
Uri Guttman ------ [email protected] -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/