in reply to one user prompt instead of many
Hmmm ... I wonder if glob can handle {}'s ... glob "C:/input/*.{htm,doc,pdf}". Not really that important, I suppose.
You probably want to grep here...
my @htm_files = glob "C:/input/*.htm"; my @doc_files = glob "C:/input/*.doc"; my @pdf_files = glob "C:/input/*.pdf"; # only keep the files more than 3 days old. my @oldfiles = grep { -M $file > 3 } (@htm_files, @doc_files, @pdf_fil +es); # if we have any such files... if (@oldfiles) { print "Delete files older than 3 days? [Y or N] \n"; chomp ($cleanup = <STDIN>); if ($cleanup =~ /Y/i) { unlink foreach @oldfiles; } else { print "\n <<No files deleted at this time>>\n"; } } else { print "\n No files to delete\n"; }
|
|---|