Musing about its efficiency therefore seems like a rather pointless excercise. </code>
I just don't see the point in looping twice when a single loop will do. Each loop has its overheads regardless of how many elements are involved, so why incur them twice when the readability gain is low? In fact IMO a lot of maintenance programmers won't even know what 'grep' does but will probably guess correctly what 'next if' does. So you aren't really improving readability for the price of a definite efficiency loss.
I've only seen one or two situations where I felt 'for grep' or 'map grep' made much sense. *shrug* :-)
First they ignore you, then they laugh at you, then they fight you, then you win.
-- Gandhi
In reply to Re^4: The trouble with Perl Idiom
by demerphq
in thread The trouble with Perl Idiom
by demerphq
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |