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