On Tue, Feb 10, 2004 at 11:21:15AM +0100, Roger Grosswiler ([EMAIL PROTECTED]) wrote: > hi list, > > i'd like to try a first perl-script that should: > > -define todays date > -define todays date minus one week > -find in a special directory files, that contain ddmmyy > -remove them > > ..since i am an absolute beginner in programming...i think, if i can read > out this directory, i can find the files with regexp.
I don't have a lot of time to elaborate since I'm at work right now but this is how I handled a similar problem. I don't present this as great but it has worked for me so far. If you have questions fire away. Later, maybe tonight, I will be able to respond. Kent #!/usr/bin/perl use warnings; use strict; # epoch time "three weeks ago" my $t_w_a = (time - 1814400); # ILL file directory my $ill_dir = "/var/www/ssl-docs/illreq"; opendir(IDIR, $ill_dir) || die "Can't open $ill_dir: $!"; # delete any files with mtime older than 21 days while(defined(my $file = readdir IDIR)) { next if $file eq '.' or $file eq '..'; my $modified_time = (stat("$ill_dir/$file"))[9]; if ($modified_time <= $t_w_a) { unlink("$ill_dir/$file"); } } closedir IDIR or die "Can't close $ill_dir: $!"; -- "Efficiency is intelligent laziness." -David Dunham -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>