This queue is for tickets about the Text-CSV_XS CPAN distribution.

Report information
The Basics
Id:
21530
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
HMBRAND [...] cpan.org
Requestors:
cat [...] reptiles.org
Cc:
AdminCc:

BugTracker
Severity:
Important
Broken in:
0.25
Fixed in:
0.26



Subject: getline() does not return documented value at end of filehandle
Date: Sat, 16 Sep 2006 22:19:40 -0400 (EDT)
To: bug-Text-CSV_XS@rt.cpan.org
From: Cat Okita <cat@reptiles.org>
The documentation at http://search.cpan.org/~jwied/Text-CSV_XS-0.23/CSV_XS.pm states: getline $columns = $csv->getline($io); This is the counterpart to print, like parse is the counterpart to combine: It reads a row from the IO object $io using $io->getline() and parses this row into an array ref. This array ref is returned by the function or undef for failure. getline() does not return undef at eof - it returns an empty array when the filehandle hits eol. By perl5 syntax, an empty arrayref is always true, which is a notably different result from undef. As a result, the following code will loop endlessly, rather than exiting at the end of the file: #!/usr/bin/perl -w use strict; use Carp; use Text::CSV_XS; open my $fh, "<", $ARGV[0]; my $csv = Text::CSV_XS->new({'binary' => 1}); my $linenumber = 0; LINE: while (my $row = $csv->getline($fh)) { my $line = join ', ', @$row; $linenumber++; print "$linenumber: $line\n"; } print "LINES: $linenumber\n"; undef $fh; ========================================================================== "A cat spends her life conflicted between a deep, passionate and profound desire for fish and an equally deep, passionate and profound desire to avoid getting wet. This is the defining metaphor of my life right now."
Subject: getline () does not return documented value at end of filehandle
Fixed in the upcoming 0.26 Thanks for the report. The regression has been added to t/70_rt.t


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.