Subject: | IO::InnerFile readline() in list context |
Date: | Sat, 26 Feb 2011 10:11:11 +1100 |
To: | bug-IO-stringy [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
In IO::InnerFile 2.110 with recent debian perl 5.10.1 a readline() in
list context only returns one line, where I believe it should return all
remaining lines of the file.
foo.pl below prints the first line of /etc/passwd, where I believe it
should print them all. Printing them all is what you get for instance
from changing the readline <$inner> to <$outer>.
Something like what IO::ScalarArray does would seem likely,
sub READLINE { wantarray ? shift->getlines(@_) : shift->getline(@_) }
with a rearrangement so READLINE calls getline instead of the other way
around, and adding a getlines perhaps like IO::ScalarArray also has.
#!/usr/bin/perl -w
use strict;
use IO::File;
use IO::InnerFile;
my $outer = IO::File->new('</etc/passwd') || die;
my $inner = IO::InnerFile->new($outer, 5, -s $outer) || die;
my @lines = <$inner>;
print @lines;
exit 0;