eof tries to read a byte from the handle, then rewinds the file. Basically, it's a kludge.
Yes, eof is a kludge. But it's also a supported language feature. Using it only required the addition of a line of code and a small change in another. Rather than figuring out how to eliminate it, I chose to spend my time adding error checking to the input. ;-)
I do like your algorithm better though. ++
Update: Putting your open in the unless block changes the scope of your $fh variable though. It'll be lexical to the unless block.
-sauoq "My two cents aren't worth a dime.";
In reply to Re: Re^5: head truncate
by sauoq
in thread head truncate
by zentara
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |