in reply to Perl System command
I'm assuming you're using Windows... DEL is part of CMD.EXE (or Command.COM) not a program in its own right... perhaps you should look at unlink (perldoc -f unlink) instead?
HTH - MarkUpdate:
Your system("echo %errorlevel%") call is spawned in a different CMD.EXE than your system("del tmp.txt"); so even if it worked it wouldn't be what you wanted... If you need to know if the file was there first you can do
#simplest format if (-e $filename){ if ((unlink($filename)) { print STDERR "File $filename deleted.\n"; }else{ print SDTERR "Couldn't delete $filename $!\n"; } }else{ print STDERR "File didn't exist\n"; }
|
|---|