in reply to Cleaning file

If you just open the file in write mode and then close it, that should do what you want.

open(my $handle, ">", $filename); close($handle)

From perlfunc:

 
If MODE is ’>’, the file is truncated and 
opened for output, being created if necessary.  
-Pileofrogs