use strict; use warnings; use List::Util qw( max ); use POSIX qw( ceil ); my @a = qw(un deux trois quatre jedan dva tritcheteri one two three); my $cols = 4; my $width = (max map length, @a) + 1; my $rows = ceil(@a / $cols); for my $r (0..$rows-1) { for my $c (0..$cols-1) { next if (my $i = $r * $cols + $c) > $#a; printf('%-*s', $width, $a[$i]); } print("\n"); } #### use strict; use warnings; use List::Util qw( max ); use POSIX qw( ceil ); my @a = qw(un deux trois quatre jedan dva tritcheteri one two three); my $cols = 3; my $width = (max map length, @a) + 1; my $rows = ceil(@a / $cols); for my $r (0..$rows-1) { for my $c (0..$cols-1) { next if (my $i = $r + $c * $rows) > $#a; printf('%-*s', $width, $a[$i]); } print("\n"); }