Perl 以数组形式将数据打印到csv文件

Perl 以数组形式将数据打印到csv文件,perl,export-to-csv,Perl,Export To Csv,我尝试将数组打印到csv文件中,为此,请编写以下代码: use strict; use warnings; use Text::CSV; use Text::CSV_XS; my $csv = Text::CSV_XS->new(); my $file = "data.csv"; open(OUT, '<', $file) or die "Could not open '$file' $!\n"; my @columns = (qw/what ever the items

我尝试将数组打印到csv文件中,为此,请编写以下代码:

use strict;
use warnings;

use Text::CSV;

use Text::CSV_XS;

my $csv = Text::CSV_XS->new();

my $file = "data.csv";

open(OUT, '<', $file) or die "Could not open '$file' $!\n";

my @columns = (qw/what ever the items are for each columns/);

my $status = $csv->print(OUT, \@columns);
使用严格;
使用警告;
使用Text::CSV;
使用Text::csvxs;
my$csv=Text::csv_XS->new();
my$file=“data.csv”;

open(OUT),您不能将裸字文件句柄用作子例程参数。请改用词法文件句柄:

open my $out, '<', $file or die ...;
$csv->print($out, \@columns);
此外,您还打开了文件进行读取(

$csv->print(*OUT, \@columns);