#!/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
In reply to Re: Transpose a matrix of chars
by neniro
in thread Transpose a matrix of chars
by dirac
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |