Re: how to test if an element belongs to an array or hash



biomahui@xxxxxxxxx wrote:

>
> A new question related:
>
> if I created a hash, $set{$a}{$b}=1, I can get the keys of $b for a
> given $a, using "keys %{$set{$a}}";
>
> My question is, Is there any function that can test the existence of an
> element belongs to $b for a given $a?
> Thanks!


I think you mean this:-

if (exists $set{'fruit'}{'pear'}) {
print "Pear is a fruit\n";
}
else {
print "Pear in not a fruit\n";
}

If not, please clarify.


--
Brian Wakem


.



Relevant Pages

  • Re: hash key names
    ... >> I have keys with periods in them: ... >> my %hash; ... > That will produce a bunch of errors. ... Prev by Date: ...
    (perl.beginners)
  • Re: Pb of key in a table
    ... Dave Weaver wrote: ... > How can a hash key be undefined? ... *value* for defined'ness, not the keys. ... Prev by Date: ...
    (comp.lang.perl.misc)
  • Re: creating a hash
    ... I use to put this hash in a file and get the content using ... And I want to be able to get the dupplicate keys in order to delete them ... Prev by Date: ...
    (perl.beginners)
  • Re: keys of hash of hashes
    ... > I have a hash that im trying to get the keys. ... > Luxury, Thatched Chalet', Luxury Safari Tent etc. ... Prev by Date: ...
    (perl.beginners)
  • Re: how to test if an element belongs to an array or hash
    ... element belongs to $b for a given $a? ... Prev by Date: ...
    (comp.lang.perl.misc)