Re: can't get unlink to work on windows

From: Chris Mattern (matternc_at_comcast.net)
Date: 12/29/04


Date: Wed, 29 Dec 2004 11:42:42 -0500

jan_buys@hotmail.com wrote:

> Hi,
>
> Hope this is a quickie for you toughened perl gods.
>
> I am using unlink in a CGI script (server currently running under my
> own admin account) but I can't get it to remove a file with the unlink
> command. The script should be cross-platform, so I can't use a system
> command for this :
>
> code :
> $remfn = $FilePath.$PlatformSlash.$NFN;
> my $cnt = unlink (qw|"$remfn"|); # db too
> open (DEBUG, "> test.txt"); # db
> print DEBUG "$remfn, $cnt, $!"; # db
> close (DEBUG); # db
>
> my debug file then shows :
> c:\Program Files\Apache
> Group\Apache\htdocs\noticeboard\uploads\UPL_8848.upl
> , 0, No such file or directory
>
> Which is strange, because the file IS there.
>
> btw : tried these variants too :
> unlink "$remfn";
> unlink ("$remfn");
>
> Thanks for any help !

Are you word wrapping stuff? What you claim your debug file shows has line
feeds in it. Are they in the debug file? If they are, are they in the file
name? In particular, is it possible that $NFN has a trailing line feed as
your report from the debug file seems to show? Perhaps you need to chomp
$NFN after you get from wherever you get it from.

-- 
             Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"