in reply to overwrite a file

Do you mean you're trying to create a "copy" subroutine to use in a program? Something like:
sub copy( source, destination ) { open SOURCEFILE "source"; open DESTINATIONFILE "destination"; while (<SOURCEFILE>) { print DESTINATIONFILE ; } close DESTINATIONFILE; close SOURCEFILE; }

If so, then maybe the problem is in how you're opening the destination file.

open FILE "<$file";
to read a file
open FILE ">$file";
to write to a file, creating it if necessary
open FILE ">>$file";
to append to a file, creating it if necessary

Forget that fear of gravity,
Get a little savagery in your life.