The stupid question is the question not asked | |
PerlMonks |
Re: lsearch for perl?by Zaxo (Archbishop) |
on Dec 05, 2005 at 15:46 UTC ( [id://514159]=note: print w/replies, xml ) | Need Help?? |
Sure, grep will simplify that, with a minor change in behavior - maybe for the better. That will return the empty list for false, and otherwise a list of each index that succeeds Usage becomes, for your example, so all instances of $item are removed from the array. The reverse call is needed to preserve the indexes from being shifted out of sync by splice. An alternative is to define a winnow() function to do it all: That is maybe less flexible, but I think cleaner. After Compline,
In Section
Seekers of Perl Wisdom
|
|