go ahead... be a heretic | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Regarding in_list I personally would prefer either:
if you really care about the count (and want to use grep) or if you want fast then:
using the for modifier avoids creating and managing an extra scope (like grep,map and for statements) and avoiding the slice I think is more efficient. Afaik perl will have to create the sliced list first before iterating so you are really just copying the whole array which could get expensive for a large list. Anyway heres an interesting/useful one :
Which is a nice trick to reduce the cost of the tight loop. Dunno if more modern perls have been optimised enough that these tricks are unnecessary though. Its been a while since I benchmarked this stuff last.
---
demerphq First they ignore you, then they laugh at you, then they fight you, then you win.
In reply to Re: Common Perl Idioms
by demerphq
|
|