If not, I think it will do what you're looking for. $File::Find::name contains the full path to whatever you're working with at the moment. You pass it a sub to call for each file/dir it finds. Here's one that I use to purge all files older than 14 days.
Hope that helps.. Richsub process_file { my($name, @contents); $name = $File::Find::name; #change /'s to 's for the attrib command on windows platforms $name =~ s#/#\\#g; if (!-l && -d _) { unless (@contents = <$File::Find::name/*>) { if (rmdir($File::Find::name)) { print LOGFILE "Directory $name empty - deleted.\n" +; } elsif ((!`attrib -R $name`) && (rmdir($File::Find::name))) + { print LOGFILE "Directory $name empty - deleted(Read On +ly).\n"; } else { print LOGFILE "ERR: Can't delete $name - $!\n"; } } } else { my ($age, $size, $max_age); $max_age = 14; $age = int( -M ) < int( -C ) ? int( -M ) : int( -C ); if ($age > $max_age) { $size = (-s); if (unlink($File::Find::name) ) { print "$File::Find::name, - $age days, $size \n"; print LOGFILE "$File::Find::name, - $age days, $size \ +n"; } elsif ((!`attrib -R $name`) && (unlink($File::Find::name)) +) { print LOGFILE "$File::Find::name, - $age days, $size ( +Read Only)\n\n"; } else { print LOGFILE "ERR: Couldn't delete $File::Find::name +- $!\n"; } } } }
In reply to Re: My kingdom for a substring
by rchiav
in thread My kingdom for a substring
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |