http://qs321.pair.com?node_id=647998


in reply to overwriting a file

As long as you open the file with mode >, the old contents should be gone already.

Assuming you are opening with mode +>, +< or similar (for read/seek/write combos, particularly useful with file locking), this is a real problem, and the solution you are looking for is truncate, probably with tell:

truncate( OPENFILE, tell(OPENFILE) );

(Alternatively, if you can safely truncate to 0 before you even start writing, that might be clearer.)

print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!