This is kind of cool. You are right, grep is probably under used. I also like the use of pre-increment which will, as a bit of perl magic, initialize $i for you. (actually so will post increment but as it turns out, aside from the offset issue here, preincrement is generally more efficiant for the compiler).#For every $n element in @List grep {not ++$i % $n} @List;
In reply to RE: Get every nth element
by Adam
in thread Get every nth element
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |