Subject: | Text::CSV blocks unnecessarily on interactive input. |
Date: | Mon, 1 Dec 2014 22:30:20 +0000 |
To: | "bug-Text-CSV [...] rt.cpan.org" <bug-Text-CSV [...] rt.cpan.org> |
From: | Berk Akinci <Berk.Akinci [...] corero.com> |
I'm using Text::CSV_PP interactively. (Yes, it's a little unexpected...)
When used interactively, "getline" method "falls behind" by a line. It takes two lines of input for getline() to return. From then on, everything is behind by a line. I found the problem to be the use of "eof" perl function on the interactive input. It blocks, waiting on the second line! My workaround patch is below. Please consider for inclusion.
There are other uses of "eof", but this one has so far been the only one that blocks unexpectedly. It would be even better to give us a method to suppress _AUTO_DETECT_CR. This wouldn't work interactively, anyway. In my case, the attached patch seems sufficient.
Thanks,
Berk Akinci
Version: Text-CSV-1.32
Perl: This is perl 5, version 14, subversion 2 (v5.14.2) built for arm-linux-gnueabi-thread-multi-64int
uname -a: Linux x 3.2.40 #66 Wed Aug 6 17:49:48 EDT 2014 armv7l armv7l armv7l GNU/Linux
--- cpan/Text-CSV-1.32/lib/Text/CSV_PP.pm 2014-12-01 17:04:32.000000000 -0500
+++ lib/perl/Text/CSV_PP.pm 2014-12-01 17:04:33.000000000 -0500
@@ -741,7 +741,7 @@
sub _return_getline_result {
- if ( eof ) {
+ if ( $_[0]->{_AUTO_DETECT_CR} == 1 && eof ) {
$_[0]->{_AUTO_DETECT_CR} = 0;
}