in reply to Re^5: head truncate
in thread head truncate

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.";