sub split_into_three { my $first = @_; my $last = int($first / 3); $first -= $last; $first -= int($first / 2); return [ @_[0..$first-1] ], [ @_[$first..$#_-$last] ], [ @_[$#_-$last+1..$#_] ]; } my ($first, $second, $third) = split_into_three(@everything); my @buckets = split_into_three('a'..'z'); print join("\n", map { join(" ", @{$_}) } @buckets), "\n"; # a b c d e f g h i # j k l m n o p q r # s t u v w x y z