我在CSV文件中逐个打印110000个文件,但它只打印文件中的第一个结果
#!/usr/bin/perl
use strict;
use warnings;
use Switch;
use Text::CSV_XS;
use Data::Dumper;
use File::Slurp;
use LWP::Simple;
use Parallel::ForkManager;
my @links=("doba_media26.upcs");
my $pm = new Parallel::ForkManager(16);
foreach my $linkarray (@links) {
$pm->start and next; # do the fork
my $csv = Text::CSV_XS->new ({
binary => 1,
eol => "\r\n",
sep_char => "\t"
}) or die "Cannot use CSV: ".Text::CSV_XS->error_diag ();
open my $sample, ">:encoding(utf8)", $linkarray."_sample.csv"
or die "result.csv: $!";
my @lines = read_file( $linkarray );
my $numLines = @lines;
foreach my $line(@lines) {
eval {
my @tabs;
print $line;
push (@tabs,"");
push (@tabs,"");
push (@tabs,"");
push (@tabs,$line);
my @line = "\n";
$csv->print($sample,\@tabs);
}
};
if ($@) {
redo;
sleep(1200);
}
$pm->finish; # do the exit in the child process
}
$pm->wait_all_children;
该文件有11,000个结果,但上面的代码只打印csv文件中的第一个字段?