|
|
Question : unlink/file list
|
|
I think I'll give this one more try. I think I've gotten close. But I'm still not able to remove the files from the "docs" directory. The "data/filedel.txt" gets stripped of files by running the procedure below. That's not what I'm shooting for. I can print @deller after the "opendir", so apparently the list exists. I just don't know what's wrong/missing.
Thanks...again Snippet:>>>>>>> #!/usr/bin/perl use CGI qw(:standard :shortcuts center); Main: { print header;
open(TXT, "<../data/filedel.txt")||die("Can't openTXT\n"); # Reads from this file to get files to delete #file created from previously run procedure--(file name including ext--comma delimited) $dellist="../data/filedel.txt"; #create scalar value of file close (TXT); open DELL,"<$dellist" or die "Can't open DELL\n"; @deller=; #Convert to LIST close (DELL);
unless(opendir DOCS,"../docs/") #open directory containing files to "delete" { print center("Cannot Find Directory"); exit; }
closedir DOCS;
unlink @deller; #delete files whose names appear on the list exit; }
<<<<<<<<<<<<<<<<<<<<<<GINAL QUESTION<<<<<<<<<<<<<<<<<<<<<<<
|
Answer : unlink/file list
|
|
i would insert the foll code snippet in your script and try...
Main: { print header;
$dellist="../data/filedel.txt"; #create scalar value of file open DELL,"<$dellist" or die "Can't open DELL\n"; @deller=; #Convert to LIST close (DELL);
unless(opendir DOCS,"../docs/") { #open directory containing files to "delete" print center("Cannot Find Directory"); exit; } closedir DOCS;
#delete files whose names appear on the list ##NOTE: unlink doesn't report which filenames it couldn't delete, only how many it did delete. unlink(@deller) == @deller or die "Couldn't unlink all of @deller: $!\n"; exit; }
|
|
|
|
|