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

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

Thread Next
From:
Josh Purinton
Date:
May 1, 2003 09:50
Subject:
Re: [perl #22010] open(F, "<&DATA") fails silently
Message ID:
20030501165036.GA18737@lambda.purinton.org
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 <perlbug20030421.5.jp@xoxy.net>

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About