sub split_to_n { my $n = shift; my @p = map {(@_)*$_/$n} 0..$n; @_ = reverse @_; map {[reverse @_[$p[$_-1]..($p[$_]-1)]]} reverse 1..$n; }