perl橫豎轉換

gaorongchao1990626發表於2013-04-09




#system 'cat 11.csv | perl -nale 'for (0 .. $#F) { $r[$_] .= $F[$_] . " " };  END { print for @r }' > 11.txt';
#system 'cat 12.csv | perl -nale 'for (0 .. $#F) { $r[$_] .= $F[$_] . " " };  END { print for @r }' > 12.txt';
#system 'cat 13.csv | perl -nale 'for (0 .. $#F) { $r[$_] .= $F[$_] . " " };  END { print for @r }' > 13.txt';
#system 'cat 14.csv | perl -nale 'for (0 .. $#F) { $r[$_] .= $F[$_] . " " };  END { print for @r }' > 14.txt';
#system 'cat 15.csv | perl -nale 'for (0 .. $#F) { $r[$_] .= $F[$_] . " " };  END { print for @r }' > 15.txt';
#system 'cat 16.csv | perl -nale 'for (0 .. $#F) { $r[$_] .= $F[$_] . " " };  END { print for @r }' > 16.txt';
open my $fh, "aaa.txt" or die $!; 
while (<$fh>) 
{ 
	chomp; 
	my @F = split / /; 
	for (0 .. $#F)
	{ 
		$r[$_] .= $F[$_] . " "; 
	}
}
close $fh; 
open $fh2, ">bbb.txt" or die $!;
print $fh2 $_, "\n" for @r;


相關文章