#!/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"; }
Abigail
In reply to Re: Printing an array in columns - improvements?
by Abigail-II
in thread Printing an array in columns - improvements?
by fireartist
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |