Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Flag variablesby KPeter0314 (Deacon) |
on Mar 03, 2003 at 15:35 UTC ( [id://240056]=note: print w/replies, xml ) | Need Help?? |
Not to be a troublesome monk, but I have a twist on the Wisdom that oakbox seeks. I too being just a learning monk with nobody local to learn from. Given that the code in the original post is not what we should aspire to, what about looking for multiple matching items in the array? Say for instance that the array is not unique and you want to look for an instance of "foo" and also "bar". Either of these may show up once, many times, or even never. In any case we only wan to run the resulting action once Would the code from blakem be the best? I hadn't used the grep fuction in this way and am glad to be illumined to it. It would seem to be expensive though if @somearray was rather large to iterate through it multiple times. Or, would there be a better way than expanding the code to this if the @somearray were large: Note: you wouldn't want to jump out with a "last" as that would prevent you from checking for other conditions.
-Kurt
In Section
Seekers of Perl Wisdom
|
|