#!/c:\progra~1\perl\bin\perl.exe -w # program modified to be a starting program for Homework B use strict; # here you can extract the command line parameters # and decide whether to run the program delete_old_files("c:\\temp", 1); ############################################################################### sub delete_old_files { my ($dirpath, $daysold)= @_; opendir(DIR, $dirpath) or return; my @filelist=readdir(DIR); closedir(DIR); my $i; foreach $i (@filelist) { next if (($i eq ".") or ($i eq "..")); my $file=$dirpath."\\".$i; if (-d $file) { delete_old_files($file, $daysold); } elsif ((-f $file) && (-M $file > $daysold) ) { unlink($file); } } # here you can decide whether to delete the folder }