http://qs1969.pair.com?node_id=124850


in reply to Deleting files older then 48 hours..

In the spirit of TMTOWTDI, here's a quick script that doesn't require any modules other than strict:
use strict; my $dir = "/home/sscripts/public_html/kage/"; my %ignore = ( 'blahblah.zip' => 1 ); my $seconds = 60 * 60 * 48; my $now = time(); print ("Content-type: text/html\n\n"); opendir ITEMS, $dir; my @files = grep !/^\./, readdir ITEMS; closedir ITEMS; chomp @files; chdir $dir; foreach my $file ( @files ) { if ( -d $file || defined $ignore{$file} ) { next } my $mod_time = ( stat($file) )[9]; my $when = localtime( $mod_time ); print ("$file $when<br>\n"); if ( $now - $seconds > $mod_time ) { unlink $file; } }
That's my 16**(1/4) cents. HTH
___________________
Kurt