in reply to unlinking old files
In any case, I'll assume for now that you have a good reason. Here's some code that would do what you want:
#!/usr/bin/perl -w use strict; use CGI::Carp; my $dir = "/tmp/wwwtrash"; opendir DIR, "$dir" or die "Couldn't open directory $dir: $!"; my @files = grep { (-f "$dir/$_") && (-M "$dir/$_" > 1) } readdir(DIR) +; closedir DIR; unlink @files or die "Couldn't unlink files in $dir: $!"; # rest of your script
Update:
As lindex pointed out, dying is bad CGI manners since it tends to put nothing useful in the logs or the user's browser. Add use CGI::Carp; after the strict pragma (done above) and eveything should be taken care of.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: unlinking old files
by lindex (Friar) on Jul 22, 2000 at 03:29 UTC |