I have a script that uses Text::CSV to build a HoH structure from a CSV file. The script stopped at the last line of the following code:
# snippet of the code
sub buttons
{
my $csv_file = '/home/user/mydomain.com/cgi-bin/files/spreadsheet.csv'
+;
my $csv = Text::CSV->new ( { allow_whitespace => 1, binary => 1, sep_c
+har => '|' } )
or die "Cannot use CSV: ".Text::CSV->error_diag ();
my $csv_fh;
open ($csv_fh, "<:encoding(utf8)", $csv_file) or die "$csv_file : $!";
$csv->column_names($csv->getline($csv_fh));
Here's the error that I found in the error logs:
[error] [client 66.200.100.66] sv_upgrade from type 8 down to type 6
+at myscript.pl line 672, <$csv_fh> line 1.
Line 672 is the column_names line above.
Perl version 5.10.0
I recently appended a couple lines to the spreadsheet.csv file.
I took a look at the docs, but I'm in over my head here. Any hints appreciated.
The rest of the sub follows
my @buttons;
while (my $row = $csv->getline_hr($csv_fh))
{
push(@buttons, $row) unless ($. == 1);
}
my %buttons_hash = "";
for my $button (@buttons)
{
my $this_item_name = ${$button}{item_name};
${buttons_hash}{$this_item_name} = $button;
}
return \%buttons_hash;
}