#!/usr/bin/perl use strict; use warnings 'all'; my @array = qw/one two three four five six seven eight nine ten/; my $cols = 3; my $max = -1; $_ > $max && ($max = $_) for map {length} @array; while (@array) { print join " " => map {sprintf "%-${max}s" => $_} splice @array => 0, $cols; print "\n"; }