At the cost of a temporary counter variable
my $c = -$l; push @b, [ grep {defined $_} @a[($c+=$l)..($c+$l-1)] ] for 0 .. $#a/$l
if you don't mind extending @a to a multiple of $l ;-)
<update>
Oops - almost identical to JohnGG's solution above - and his uses $_ as counter. hrm :-/
push @b, [ grep {defined $_} @a[$_*$l .. ($_*$l+$l>$#a ? $#a : $_*$l+$ +l-1)] ] for 0 .. $#a/$l;
This one doesn't extend @a. But readable, well... it's the best I can contrieve in a single line (up to ";" that is).
</update>
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
In reply to Re: Syntactically cool list of lists
by shmem
in thread Syntactically cool list of lists
by jettero
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |