Welcome to the Monastery | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Ok, as other replies have said the best way to do this is to not do this. :-) Use a hash in the first place when you think you will need "isamememberof" relationships.
But if you must do this for some reason then as the other replies have said you can use grep. Except that you probably dont want to do that. :-) grep() is slow for this type of job. grep() is intended for finding "all the members of an array that meet a set of criteria", but what you have asked for is "find if there is an element in the array that meets a set of criteria" which is pretty different. A simple (practically) textbook solution is Where $found will whether the array contains a value (in the case numerically) equivelent with $scalar. A way to do this as an expression (ie in the if you gave as an example) is here Of course you could set it up in a sub or do any number of other things.... Remember using a hash in this situation is much smarter than using either this solution or grep()
--- demerphq In reply to Re: Set Operators
by demerphq
|
|