我有一个包含数组列表的数组。我想从每个数组中取一行后写出这些数组的值。我尝试下面的代码,但它只给出每个数组的第一行。
my @merged = (@$res1, @$res2, @$res3, @$res4);
my @shuffle = (@merged[0],@merged[4],@merged[1],@merged[6],@merged[2],@merged[5],@merged[3],@merged[7]);
unlink "threadperl.pl";
open (threadfile, ">threadperl.pl");
print threadfile "use threads;\n\n";
print threadfile "use File::Copy;\n\n";
my @fh;
#create an array of open filehandles.
@fh = map { $_->[1] } @shuffle;
my $output;
foreach (@fh){
my $line = $_;
print $line;
if (defined $line){
#Special case: might not be a newline at the end of the file
#add a newline if none is found.
$line .= "\n" if ($line !~ /\n$/);
$output .= $line;
}
}
print threadfile $output;
close threadfile;
任何人都可以帮助我,谢谢你。