Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^4: binmode and one-liners (eof reads)

by tye (Sage)
on Jul 02, 2007 at 20:55 UTC ( [id://624550]=note: print w/replies, xml ) Need Help??


in reply to Re^3: binmode and one-liners
in thread binmode and one-liners

After my previous reply, I found the time and facilities and ran a quick test and found two mistakes in your suggestion. First, it is eof() (with parens) not eof without parens that triggers ARGV magic.

Second, as I suspected, eof() does read ahead:

% perl -del existingFile.txt DB<1> x eof() 0 '' DB<2> x sysseek(*ARGV,0,1) 0 4096 DB<3>

So, if on a platform where binmode mattered, binmode() would not have been in effect for the first 4096 (resulting) bytes of the file. (But note that you don't need such a platform to perform this test.) Part of the problem here is that the impact of binmode is handled by the underlying I/O layers, not by Perl, so the bytes pre-read have already passed through the layer where binmode would be applied (but wasn't).

If there is some way to get eof without parens to trigger an ARGV-magic implicit open, then I couldn't figure it out and so didn't test it. So please describe it in more detail.

- tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://624550]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-23 13:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found