UPDATE: It turns out that it was a problem with printing to STDERR in my version of Apache2. Now that I have upgraded Apache2 to the latest Debian packages, the problem is gone. Thanks all for your help.

I'm having trouble with Text::CSV_XS. I'm using it most simply, and I don't understand why things are failing. I am not getting any error messages, the script (which is a CGI-script) just hangs indefinitely, until the web server ultimately times out. I have narrowed the problem down to the following (simplified) function.

Please notice the comments EXAMPLE LINE 1 and EXAMPLE LINE 2. If I comment either one (or both) of those out, everything works fine. If I leave them both as they are now, uncommented, the script hangs and I never get an error message in my error logs. I don't understand what's causing this or how to fix it.

$fh is a filehandle created by CGI.pm and retrieved using my $fh = $cgi->upload('product_list');
sub validate_data { my ($self, $fh) = @_; my $csv = new Text::CSV_XS({sep_char => "\t"}); my $headings = <$fh>; # Pull the column names off the top $csv->parse($headings) or return; my @headings = $csv->fields(); print STDERR Dumper(\@headings); # EXAMPLE LINE 1 while(my $line = <$fh>) { if($csv->parse($line)) { my %hash; my @fields = $csv->fields(); print STDERR Dumper(\@fields); # EXAMPLE LINE 2 } } return 1; }

I am using: I forgot to mention: Dumping this data isn't really the important part. I'm using it to build a data structure, but any time I try to access data in the data structure, the script hangs!

Edit: I have switched to Text::Delimited and when using Dumper to see those results I get errors again. I can access all the values fine, I just can't view them with Dumper. It always hangs and the program won't exit. I have a bad feeling about this.

In reply to Script Hanging w/Data::Dumper and Text::CSV_XS by saberworks

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.