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

Re: [perl #22010] open(F, "<&DATA") fails silently

Thread Next
Josh Purinton
May 1, 2003 09:50
Re: [perl #22010] open(F, "<&DATA") fails silently
Message ID:
On Wed, Apr 30, 2003 at 12:34:53PM -0000, Nick Ing-Simmons wrote:
> any file handle which is buffered by stdio will have file position "wrong"
> when used as in Subject: line

Not exactly. Without the getc(), your example will print "FOO=0 BAR=0"
for any file handle except DATA.

> #!perl
> open(FOO,__FILE__);
> my $a = getc(FOO);
> open(BAR,"<&FOO");
> print "FOO=",tell(FOO)," BAR=",tell(BAR),"\n";
> __END__

Normally, until the script explicitly reads/writes/seeks from F (or explicitly
passes F to another process that does so), tell(F) == sysseek(F, 0, 1).  With
DATA however, this is not guaranteed.  How about documenting this difference?

Josh Purinton <>

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