in reply to printing multiple arrays in column format??
This one is more generalized and doesn't modify the contents of the arrays. It's clunkier than jasonk's but gives you another option if you need it. It could be cleaned up and made more concise I'm sure ...
use strict; sub array_cols { my $array_ref; my $n = 0; foreach $array_ref (@_) { $n = scalar(@$array_ref) if (scalar(@$array_ref) > $n); } for (my $i = 0; $i < $n; $i++) { foreach $array_ref (@_) { printf "%-12.12s ", $array_ref->[$i]; } print "\n"; } } my @array1 = (qw/one two/); my @array2 = (qw/three four five/); my @array3 = (qw/six seven/); array_cols(\@array1, \@array2, \@array3);
|
|---|