in reply to Unlinking...

The problem is that your unlink isn't targeted at the FILE filehandle. It's trying to delete from whereever the script was run, except that it never gets there, because you're opening a directory with a file open command. Use "or die ("File open error:$!");" on the open and I bet it'll die.

You don't have to open files you are trying to delete. See unlink


Update: Let's look at your script line by line:
open(FILE,"/cgi and perl");
Problems:
  1. You didn't test for a die condition.
  2. You are opening a directory for no real reason
  3. What you are trying for is done by opendir and readdir
while(<FILE>){
problems:
  1. This will read FILE line by line (except that it's a directory), and put the line in $_ (which would never be used anyway)
unlink(<*.txt>);
This line alone should do what you want, if the script is run in the directory you want the text files deleted from.

Replies are listed 'Best First'.
Re: Re: Unlinking...
by damian1301 (Curate) on Nov 22, 2000 at 02:19 UTC
    I know I put the script in the directory below the PERL directory, that way I could open it with the script and then delete the files. Wheres merlyn when ya need him? ;-]

    Well I tried that before but it didn't work...Oh well Ill try it again..

    and i get this... Insecure dependency in unlink while running with -T switch at c:\windows\TEMP\DzTemp.pl line 3
      Your data is tainted :) If you're just trying to delete files, I'd either remove the -T, or use chdir, opendir, readdir, unlink in combo to delete the list of files.
        Ok, can I get a code example for that? because i havent gotten into that stuff in my Perl Bible yet. Thanks, you get ++ for all your help