in reply to Transpose a matrix of chars
#!/usr/bin/perl use strict; use warnings; use List::Util qw/ max /; my @rows; push @rows, [split (/\s/, $_)] for (<DATA>); my $max_index = max map { scalar @$_ -1; } @rows; for my $r (0..$max_index) { for my $c (0..$#rows) { print $rows[$c]->[$r] || ' '; print ' '; } print "\n"; } __DATA__ A B C F G u b 1 T A R S 2 P
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Transpose a matrix of chars
by dirac (Beadle) on Jul 04, 2005 at 13:02 UTC | |
by ysth (Canon) on Jul 04, 2005 at 22:42 UTC | |
by neniro (Priest) on Jul 04, 2005 at 13:31 UTC |
In Section
Seekers of Perl Wisdom