https://www.cnblogs.com/yeungchie/
#!/usr/bin/env perl #----------------------------- # Program : reverseRowCol.pl # Language : Perl # Author : YEUNGCHIE # Version : 2021.09.01 #----------------------------- use v5.10; use strict; use warnings; use List::Util qw/max/; my ($in,$out) = @ARGV; open IN,"< $in"; my @array; push @array,[split] for <IN>; close IN; my $index = max(map { scalar @$_ } @array)-1; open OUT,"> $out"; for my $i (0..$index){ printf OUT "%s\n",(join ' ',map { my @row = @$_; $row[$i] } @array); } close OUT; __END__
shell> cat txt 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 shell> ./reverseRowCol.pl txt txt1 shell> cat txt1 00 05 10 15 20 01 06 11 16 21 02 07 12 17 22 03 08 13 18 23 04 09 14 19 24