in reply to Text File

Since unlink() should work whether or not the file exists (it does nothing in the latter case), the other suggestions about adding '-e' do nothing to locate the problem, or solve it.

All system calls should be checked. When unlink() fails (as you believe to be occurring since the file remains) the system will return an error. Display the error using:

if (defined $new_file) { unlink($new_file) or die "unlink of $new_file failed: $!\n"; }

If no error message is occurring, it means that $new_file is not defined or that the unlink() is working. If the error message says something about "permission denied" then it means you do not have permission to unlink() the file from the directory. If the error message says something about "file does not exist" then it means you are not specifying the filename properly, likely because it is in a different directory.

We cannot offer any further help without the value of $! after unlink() fails.