in reply to Deleting or unlinking a file

Do you have any prove that chmod and unlink were executed? Maybe $file_name has the wrong value, and so the '-e' test failed, and none of the if loop executed. I suggest expanding your test to:

if ( -e $file_name ) { say "Deleting $file_name." chmod 0777, $file_name or die "Could not delete $file_name: $!; unlink $file_name; } else { say "In the else branch: '-e $file_name was false'."; }

Update - added missing $$$$

As Occam said: Entia non sunt multiplicanda praeter necessitatem.

Replies are listed 'Best First'.
Re^2: Deleting or unlinking a file
by Anonymous Monk on Mar 15, 2011 at 02:11 UTC

    It is entering the if loop for sure,I can see a debug print statement I added getting printed but the actual file is still not getting deleted.