On Feb 10, 2004, at 4:21 AM, Roger Grosswiler wrote:

hi list,

Hello.


i'd like to try a first perl-script that should:

-define todays date

print localtime(), "\n";


-define todays date minus one week

print localtime( time - 60 * 60 * 24 * 7 ), "\n"; # depending on how you define "week"


-find in a special directory files, that contain ddmmyy

my @date = (localtime(time - 60 * 60 * 24 * 7))[3..5]; $date[1]++; $date[2] = substr $date[2] + 1900, 2; my $date = sprintf '%02u%02u%02u', @date;

my $directory = 'path/to/special/dir';
opendir DIR,  $directory or die "Unable to open $directory";
my @files = grep /$date/, readdir DIR;
close DIR;

-remove them

foreach (@files) { unlink "$directory/$_" or warn "$_ could not be deleted.\n"; }


Hope that helps get you going.

James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to