develooper Front page | perl.perl5.porters | Postings from April 2003

Re: [perl #22010] open(F, "<&DATA") fails silently (perlbug20030421: message 16 of 20)

Thread Previous
Nick Ing-Simmons
April 30, 2003 05:34
Re: [perl #22010] open(F, "<&DATA") fails silently (perlbug20030421: message 16 of 20)
Message ID:
Josh Purinton <> writes:
>On Sun, Apr 27, 2003 at 07:52:29PM -0000, Nick Ing-Simmons wrote:
>> >Fair enough. Currently perldata.pod simply states:
>> >   The filehandle is left open pointing to the contents after __DATA__.
>> >
>> >It might help to add a warning like:
>> >   Unlike all other filehandles, DATA is read by perl while reading the
>> >   program.  
>> But it isn't really unlike other file handles.
>Interesting. What other file handles does the perl interpreter read from
>without the script explicitly requesting it? (And where is this behavior

It depends what you thought I meant. I was just saying that any file handle
which is buffered by stdio will have file position "wrong" when used 
as in Subject: line e.g. consider:

my $a = getc(FOO);
print "FOO=",tell(FOO)," BAR=",tell(BAR),"\n";

We have "read" one character (and my locale as such that that means 1 byte)
but that does NOT mean that the numeric fd's file posn is 1.
When I run that on my 5.8 (which defaults to :stdio)

perl /tmp/x
FOO=1 BAR=124
nick@bactrian 1003$

But :perlio "fixes" it:

nick@bactrian 1003$ PERLIO=perlio perl /tmp/x
nick@bactrian 1004$

Nick Ing-Simmons

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About