当我使用此代码时,它不会显示任何输出。它只打印表格标签。有什么我想念的吗?
这是我的 csv 文件:
id;name;city;
1;name;london;
5;testname;newyork;
7;users;amsterdam;
8;test1234;eindhoven;
这是我的 perl 脚本:
#!C:\perl64\bin\perl.exe -wT
use strict;
use warnings;
use CGI;
use CGI::Carp qw/fatalsToBrowser/;
use CGI qw(:standard);
use Text::CSV_XS;
print "Content-Type: text/html\n\n";
my $file = 'import.csv';
my $csv = Text::CSV_XS->new({
'quote_char' => '',
'escape_char' => '',
'sep_char' => ";",
'binary' => 1,
'eol' => $/
});
$csv->bind_columns (
\my $id,
\my $name,
\my $city);
open my $fh, "<", $file or die "$file: $!";
print "<table border='1'>";
while($csv->getline($fh)){
print "
<tr>
<td>$id</td>
<td>$name</td>
<td>$city</td>
</tr>";
}
print "</table>";