http://www.perlmonks.org?node_id=1019467

gautamparimoo has asked for the wisdom of the Perl Monks concerning the following question:

Hi. I want empty the file contents before writing into it again.The following is my code:

open(FILE1 , ">" ,"testing1.txt"); print FILE1 "stat"; #Do the required actions print FILE1 "stat-updated"; close(FILE1);

The output file contents will be:

stat stat-updated

But I want the output file to contain just :stat-updated.How to do it?? Do I need to close the filehandle or call truncate or something else??