Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi - I have an if condition that if the file exists then only unlink the file,for some reason,even though the file is not present in the cwd,the code tries to unlink the file,any idea why?
ERROR:- Unable to unlink files.txt: No such file or directory at perl.pl line 2
my $file_name="files.txt"; my $filename="data.txt"; if ( (-e $file_name ) || (-e $filename)) {#enters the loop even though the files do not exist unlink $file_name or die "Unable to unlink $file_name: $!"; unlink $filename or die "Unable to unlink $filename: $!"; }
|
|---|