Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

sv_upgrade error

by wrinkles (Pilgrim)
on Nov 14, 2010 at 03:56 UTC ( #871273=perlquestion: print w/replies, xml ) Need Help??
wrinkles has asked for the wisdom of the Perl Monks concerning the following question:

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/' +; 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] sv_upgrade from type 8 down to type 6 +at 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; }

Replies are listed 'Best First'.
Re: sv_upgrade error
by ikegami (Pope) on Nov 14, 2010 at 04:21 UTC

    It's surely a bug inside the module. What version of Text::CSV and Text::CSV_XS do you have installed? Did you try upgrading them?

    For the curious,

    SVt_PVNV, /* 6 */ SVt_REGEXP, /* 8 */

    If upgrading doesn't help, perhaps you could provide the data that causes the crash.

      DreamHost shared hosting. So I checked:
      perl -MModule -e 'print "$Text::CSV::VERSION\n"'
      Can't locate in @INC (@INC contains: /etc/perl /usr/local/li +b/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 /usr/share/ +perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_per +l .). BEGIN failed--compilation aborted.
      Similar result for Text::CSV_XS. I think they recently updated to 5.10.0. But drop Text::CSV just like that? What are they thinking? I'll have to notify support and/or install locally.
      Thanks for the help!
        I can't reproduce it on DreamHost ( with the info you provided.
        $ cat use strict; use warnings; use feature qw( say ); use Text::CSV qw( ); use Encode qw( encode_utf8 ); say Text::CSV->VERSION; say Text::CSV->is_xs() ? 'xs' : 'pp'; say Text::CSV->version; my $csv = Text::CSV->new ({ allow_whitespace => 1, binary => 1, sep_char => '|', }) or die; my $csv_file = encode_utf8(<<'__EOI__'); foo|bar|baz dog|cat|cow __EOI__ open(my $csv_fh, "<:encoding(utf8)", \$csv_file) or die; say for $csv->column_names($csv->getline($csv_fh)); $ perl 1.06 xs 0.52 foo bar baz

        And with a locally installed Perl 5.12.1 on the same machine:

        $ perl 1.20 xs 0.74 foo bar baz

        Yes, they updated to 5.10.0 over the summer - broke my code on there only insofaras I had to recompile the CPAN modules I was using due to the binary incompatibilities. However, to answer the question, then:

        $ perl -MText::CSV_XS -le 'print $Text::CSV_XS::VERSION' 0.52
        Looks like the one on DreamHost is somewhat dated. You may want to do a local install of Text::CSV_XS in that case. Thus far, I've not hit into any similar issue with my DBD::CSV usage, as I don't seem to have a newer version on my account.

        You're trying to load a module named "Module" instead of Text::CSV and Text::CSV_XS
Re: sv_upgrade error
by wrinkles (Pilgrim) on Nov 14, 2010 at 07:07 UTC
    OK, I'm a dumbass. OpenOffice changed the separator from "|" to "," when I edited the csv file. so I changed sep_char to "," (which I guess is the default anyway) and No Errors! :) need some sanity code, to make sure you have the right number of fields on each line, before trying to process them. pipe char is very useful as a separator in text files, as it usually doesn't conflict with anything, so no need for quoting values etc.
      the hardest line to type correctly is: stty erase ^H

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://871273]
Approved by ikegami
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2017-01-20 01:55 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (173 votes). Check out past polls.