Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/perl/bin/perl -w use strict; use warnings; use Win32; use Win32::NetResource; use Time::localtime; my ($dirh,$dirh_in, @dircontent, $file, @filenames, $age, @outputFiles + , $all_dir_path); $age=''; $dirh_in=''; my $path='C:\\files\\logs'; opendir(DIRH, "$path") || die "Cannot opendir $path: $!"; foreach $dirh (sort readdir(DIRH)) { $all_dir_path= $path."\\".$dirh; $all_dir_path=~s/(.*?)\.+//g; if($all_dir_path ne ""){ chomp($all_dir_path); opendir $dirh,$all_dir_path or die "Can't open - Check Path + - $all_dir_path"; push (@dircontent, map { $_="$all_dir_path/$_"; $_;} rea +ddir($dirh)); closedir($dirh) or die "Can't close $path"; } } closedir(DIRH) or die "Can't close $path"; foreach (@dircontent) { next unless -f; # ignore all non-normal files. $age=-M $_; if($age){ unlink($_) || die "Cannont unlink $_: $!"; print "$_ - $age\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Deleting by Age!
by Zaxo (Archbishop) on Jun 23, 2006 at 14:38 UTC | |
|
Re: Deleting by Age!
by McDarren (Abbot) on Jun 23, 2006 at 14:41 UTC | |
|
Re: Deleting by Age!
by ptum (Priest) on Jun 23, 2006 at 14:30 UTC | |
|
Re: Deleting by Age!
by leocharre (Priest) on Jun 23, 2006 at 14:39 UTC | |
|
Re: Deleting by Age!
by shmem (Chancellor) on Jun 23, 2006 at 14:46 UTC | |
|
Re: Deleting by Age!
by InfiniteSilence (Curate) on Jun 23, 2006 at 19:29 UTC |