AngusScrimm has asked for the wisdom of the Perl Monks concerning the following question:
Right now the code I have prompts the user each and every time it finds a file older than 3 days. Not quite what I want. Also, the final print command ('No files deleted...') is just there for testing purposes at this point.
Here's the code:
my @htm_files = glob "C:/input/*.htm"; my @doc_files = glob "C:/input/*.doc"; my @pdf_files = glob "C:/input/*.pdf"; my @bigarray = (@htm_files, @doc_files, @pdf_files); foreach my $file (@bigarray) { if (-M $file > 3) { print "Delete files older than 3 days? [Y or N] \n"; chomp ($cleanup = <STDIN>); if ($cleanup =~ /Y/i) { unlink $file; } else { print "\n <<No files deleted at this time>>\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: one user prompt instead of many
by Aristotle (Chancellor) on Jan 26, 2005 at 17:41 UTC | |
|
Re: one user prompt instead of many
by davido (Cardinal) on Jan 26, 2005 at 17:43 UTC | |
|
Re: one user prompt instead of many
by bibliophile (Prior) on Jan 26, 2005 at 17:43 UTC | |
|
Re: one user prompt instead of many
by Tanktalus (Canon) on Jan 26, 2005 at 18:26 UTC |