Re: how to test if an element belongs to an array or hash
- From: anno4000@xxxxxxxxxxxxxxxxxxxxxxx (Anno Siegel)
- Date: 31 May 2005 17:34:33 GMT
<biomahui@xxxxxxxxx> wrote in comp.lang.perl.misc:
> Thanks.
>
> Another question,
> Is there a way to find the keyvals from their values without using
> iteration. For instance;
>
> $set{"apple"}="fruit";$set{"pear"}="fruit";$set{"banana"}="fruit";$set{"beef"}="meal";
>
> I need to find "apple","pear" etc from "fruit".
Not without iteration, but you can use grep to speed it up and hide it
somewhat:
my @fruitkeys = grep $set{ $_} eq 'fruit', keys %set;
Anno
.
- Follow-Ups:
- Re: how to test if an element belongs to an array or hash
- From: biomahui
- Re: how to test if an element belongs to an array or hash
- References:
- how to test if an element belongs to an array or hash
- From: biomahui
- Re: how to test if an element belongs to an array or hash
- From: John Bokma
- Re: how to test if an element belongs to an array or hash
- From: biomahui
- how to test if an element belongs to an array or hash
- Prev by Date: Re: how to test if an element belongs to an array or hash
- Next by Date: Re: how to test if an element belongs to an array or hash
- Previous by thread: Re: how to test if an element belongs to an array or hash
- Next by thread: Re: how to test if an element belongs to an array or hash
- Index(es):
Relevant Pages
|