in reply to Re: What is the best way to find the key is exists or not in a hash ?
in thread What is the best way to find the key is exists or not in a hash ?
This was intended to be a joke to the OP, wasn't it?
If I really were to reimplement exists (along the lines of the proposed sub), I'd probably do something like this:
sub my_exists (\%$) { my($h,$k)=@_; $_ eq $k and return $_ for keys %$h; undef; }
Update: I saw your update, and yes, it was a joke... how stupid of me to have even the slightest doubt about it!! But your second proposal should be called "exists_ggm" instead... ;-)
|
|---|