You are saying that I shouldn't use read on ARGV. I think you are right here.
I was using it as a short notation to avoid an explicit open. This was a one-liner. It didn't matter if it could handle only one file, as the one-liner didn't even have a loop: it called read once only. However, it's quite stupid to do this, as it's much easier to read from STDIN instead and use shell redirection. In a script (not a one-liner), it's of course better to use an explicit open.
As for using 4096, I disagree with you. It doesn't really matter whether I use 2**12 or 1 << 12, they mean the same for me. (Except that 1 << 12 is a bit more verbose as it often needs to be parenthisized.) However, there's no way I'll use 4096, even in a constant definition like sub HEADER_SIZE { 4096 } instead of these. The reason is simple: once I wrote a script where I had to read a string of 256 records of 32 bytes each. I wrote 8092 instead of 8192, and I had a very bad time searching for the bug. So, I've learnt that if I want to read four kilobytes, I write 4*1024 or 4<<10 or 1<<12, but never calculate 4096 in my head.
In reply to Re^2: read ARGV ==> read on unopened filehandle
by ambrus
in thread read ARGV ==> read on unopened filehandle
by ambrus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |