I have a challenge with the perl unlink command. I use this in well established code to remove unwanted files - but recently I notice it fails with some files. I am using Windows 7, and Activstate binary build 1007 perl, v5.10.1 built for MSWin32-x86-multi-thread. Here's a code snippet...
my($no) = unlink $targ || carp "Unable to delete file $targ\n"; if ($no == 0){ printf " %s\n", $!; }else{ printf " %s\n", $no; }
So very simple... The variable $targ only ever has one file name. When the file to delete has unusual (illegal?) characters I observe the problem. For instance with a filename of
unlink reports the file deleted (and $no is set to 1 indicating one file deleted) - but in reality the file still exists. I suspect the error is generated by the tilde (~) and dollar character following directly after the directory seperator character (/), but can't figure out how to escape it.D:/Users/Dave/Documents/Personal/CV/~$rriculum Vitae - 09 June 2007.do +c
I can stat the file before calling unlink (and it is found). Does anyone have a suggestion ? Thanks in advance
In reply to unlink fails to delete files with perculiar names by DaveARoberts
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |