Closed p5pRT closed 19 years ago
Dear fellow Perl lovers\,
The Perl version i use is 5.8.6 on Linux\, Mac OS X\, and Sun Solaris 8.
The following self-contained program dies with a "read failed" message:
#!/usr/local/bin/perl -w
use strict;
my $s = \<\<'EOF'; line A line B a third line EOF
open (F\, '\<'\, \$s)
or die "Could not open string as a file";
local $/ = "";
my $ln = \
However\, if I have it read from a file with the same contents as $s instead of $s itself\, it succeeds. To wit:
#!/usr/local/bin/perl -w
use strict;
my $s = \<\<'EOF'; line A line B a third line EOF
open (F\, '>'\, "/var/tmp/Z"); print F $s; close F;
open (F\, '\<'\, "/var/tmp/Z")
or die "Could not open string as a file";
local $/ = "";
my $ln = \
This looks like a bona-fide Perl bug. Am I missing something?
Note that reading from them works fine as long as I don't touch $/.
-- Hseuming
Emails :: hseuming.chen@citigroup.com hseuming@cs.nyu.edu hseuming@gnu.mit.edu hseuming@yahoo.com hseuming@gmail.com hseuming@hotmail.com
Phones :: (908)563-0029 (o) (973)597-1801 (h) --------------------------------------------------------------_
On Sun\, May 22\, 2005 at 06:09:41AM -0000\, Hseu-Ming Chen wrote:
The following self-contained program dies with a "read failed" message:
#!/usr/local/bin/perl -w
use strict;
my $s = \<\<'EOF'; line A line B a third line EOF
open (F\, '\<'\, \$s) or die "Could not open string as a file"; local $/ = ""; my $ln = \
; die "read failed" unless defined $ln; close F; Note that reading from them works fine as long as I don't touch $/.
Yeah\, I can repeat this bug and confirm that "local $/ = ''"; is the problem. Interestingly\, "local $/;" works as does "local $/ = undef;".
-- Michael G Schwern schwern@pobox.com http://www.pobox.com/~schwern Don't try the paranormal until you know what's normal. -- "Lords and Ladies" by Terry Prachett
The RT System itself - Status changed from 'new' to 'open'
On 22 May 2005 06:09:41 -0000\, via RT Hseu-Ming Chen \perlbug\-followup@​perl\.org wrote:
The following self-contained program dies with a "read failed" message:
#!/usr/local/bin/perl -w
use strict;
my $s = \<\<'EOF'; line A line B a third line EOF
open (F\, '\<'\, \$s) or die "Could not open string as a file"; local $/ = ""; my $ln = \
; die "read failed" unless defined $ln; close F;
The bug is in PerlIOScalar_unread\, which doesn't do what it should. The following patch solves this particular problem\, but it's obviously not sufficient... it's late and I'll try to work out a proper solution another day.
==== //depot/perl/ext/PerlIO/scalar/scalar.xs#12 - /opt/bleadperl/p4/perl/ext/PerlIO/scalar/scalar.xs ==== --- /home/rafael/tmp/tmp.21342.0 2005-05-23 00:36:44.351368184 +0200 +++ /opt/bleadperl/p4/perl/ext/PerlIO/scalar/scalar.xs 2005-05-23 00:36:37.732374424 +0200 @@ -105\,11 +105\,7 @@ SSize_t PerlIOScalar_unread(pTHX_ PerlIO * f\, const void *vbuf\, Size_t count) { PerlIOScalar *s = PerlIOSelf(f\, PerlIOScalar); - char *dst = SvGROW(s->var\, (STRLEN)s->posn + count); - Move(vbuf\, dst + s->posn\, count\, char); - s->posn += count; - SvCUR_set(s->var\, (STRLEN)s->posn); - SvPOK_on(s->var); + s->posn -= count; return count; }
On 5/23/05\, Rafael Garcia-Suarez \rgarciasuarez@​gmail\.com wrote:
The bug is in PerlIOScalar_unread\, which doesn't do what it should. The following patch solves this particular problem\, but it's obviously not sufficient... it's late and I'll try to work out a proper solution another day.
Now hopefully implemented in bleadperl as :
Change 24543 on 2005/05/23 by rgs@marais
Fix [perl #35929] : PerlIO::scalar didn't understand $/ = "" because PerlIOScalar_unread was broken. Bump version number of PerlIO::scalar to 0.04.
@rgs - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#35929 (status was 'resolved')
Searchable as RT35929$