Closed p5pRT closed 12 years ago
I've run the following test with both 5.6.1 and 5.8.0 on Mac OS X\, and it looks like -T $filehandle is returning different results (and incorrect ones at that) than -T $filename.
(I added zero for "clarity".)
I haven't tested the current 5.8.1 release candidate.
-Ken
[kwilliams - Mon Jul 21 11:39:00 2003]:
I've run the following test with both 5.6.1 and 5.8.0 on Mac OS X\, and it looks like -T $filehandle is returning different results (and incorrect ones at that) than -T $filename.
================== % echo foo > file % perl -le 'print 0 + -T "file"; open $fh\, "file" or die $!; print 0 +
-T $fh' 1 0 ==================(I added zero for "clarity".)
I haven't tested the current 5.8.1 release candidate.
-Ken
I was able to recreate this still on 5.8.5 and the current blead.
There is one question that I have though. I found this little chuck
of code in pp_sys.c.
if (io && IoIFP(io)) { if (! PerlIO_has_base(IoIFP(io))) DIE(aTHX_ "-T and -B not implemented on filehandles"); PL_laststatval = PerlLIO_fstat(PerlIO_fileno(IoIFP(io))\, &PL_statcache); ...
Is this some old artifact or should a -T or -B on a filehandle cause perl to die?
The RT System itself - Status changed from 'new' to 'open'
"Steve Peters via RT" \perlbug\-followup@​perl\.org:
Is this some old artifact or should a -T or -B on a filehandle cause perl to die?
The problem with -T on a filehandle is that it requires that Perl read some of the data out of the handle and examine it for icky characters. But then that data is no longer available to the user\, so the filehandle is essentially spoiled. That is the reason that the original intention was for it to die.
With the advent of PerlIO\, it might be the case that this can be worked around. But if not\, Perl should die.
Mark Jason Dominus \mjd@​plover\.com writes:
"Steve Peters via RT" \perlbug\-followup@​perl\.org:
Is this some old artifact or should a -T or -B on a filehandle cause perl to die?
The problem with -T on a filehandle is that it requires that Perl read some of the data out of the handle and examine it for icky characters. But then that data is no longer available to the user\, so the filehandle is essentially spoiled. That is the reason that the original intention was for it to die.
With the advent of PerlIO\, it might be the case that this can be worked around. But if not\, Perl should die.
-T on a filehandle works by snooping in the buffer. This has worked ok long before PerlIO where buffer snooping could be detected by Configure. What PerlIO does is extend snooping to any platform (by using :perlio layer if :stdio is not snoopable).
This was fixed in 5.10.0.
$ perl5.8.9 -le 'print 0 + -T "file"; open $fh\, "file" or die $!; print 0 + -T $fh' 1 0
$ perl5.10.0 -le 'print 0 + -T "file"; open $fh\, "file" or die $!; print 0 + -T $fh' 1 1
@cpansprout - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#23077 (status was 'resolved')
Searchable as RT23077$