Thanks Uri and Jepp, that was exactly the information I was looking for.
----- Original Message ----- From: "Uri Guttman" <[email protected]> To: "Jeff Pang" <[email protected]> Cc: [email protected] Sent: Sunday, October 31, 2010 6:39:50 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna Subject: Re: anonymous hash reference >>>>> "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/ -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] http://learn.perl.org/
