The stupid question is the question not asked | |
PerlMonks |
Re: in_array and skipping foreachby JediWizard (Deacon) |
on Apr 13, 2005 at 14:34 UTC ( [id://447416]=note: print w/replies, xml ) | Need Help?? |
First of all: You can use loop labels to controll which loop a next or last pertains to:
But to actually answer your question: I think it would be better to use grep in a scalar context to test for the presence of an item in an array (as opposed to foreach'ing through the array doing an eq comparison).
HTH. Cheers Update: As others have suggested, a hash is better for this type of lookup A truely compassionate attitude towards other does not change, even if they behave negatively or hurt you His Holiness, The Dalai Lama
In Section
Seekers of Perl Wisdom
|
|