我试图将csv->print输出到一个文件中,我想使用的文件名在$_中,并且屏幕上csv->print命令中的数据打印是正确的。我只是想不出怎么把它放进文件里。
$_ = $ARGV[0];
s/^[^=]*=//;
while (@ARGV) {
my $file = shift;
open my $IN, '<', $file or die $!;
my $html = do { local $/; <$IN> };
$te->parse($html);
}
for my $table ($te->tables) {
#print $_."\n";
open (NEWCSV, '>> '.$_);
print NEWCSV $csv->print(*STDOUT{IO}, $_) for $table->rows;
close (NEWCSV); }
谢谢
发布于 2014-02-09 20:57:29
只需打开一个输出文件,并使用它的文件句柄而不是*STDOUT{IO}
open my $FH, '>', 'file.csv';
$csv->print($FH, $_) for $table->rows;https://stackoverflow.com/questions/21664607
复制相似问题