use strict; use warnings; my $a_rows = [qw[one two three four five six seven eight nine ten]]; my $npad = 4; my $justify = 1; rows_to_cols($a_rows, $npad, $justify); sub rows_to_cols { my ($x, $p, $j) = @_; my $m = 0; map { $m = length $_ if $m < length $_ } @$x; ($j||0) && map { $_ = sprintf "%*s", $m, $_ } @$x; @_ = map { ($")x($p||2),$_ } @$x; map { map { print substr($_, 0, 1, "") || $" } @_; print $/ } 1..$m }