my $cols = 4; for my $i (0 .. $#UACS) { print $UACS[$i], (($i + 1) % $cols ? qq{\t} : qq{\n}); } print qq{\n} if @UACS % $cols;