Just another Perl shrine | |
PerlMonks |
Re^2: Hide my ageing workby blowupp (Novice) |
on Oct 26, 2008 at 08:59 UTC ( [id://719629]=note: print w/replies, xml ) | Need Help?? |
With all the suggested weekend reading something has rubbed off &
I have disturbed the Monks again to boast that I've cracked it! Here is my perl effort; A script to rename aged files, for the Monks archives; #! /usr/local/bin/perl use strict; use warnings; use File::Find; #set the age tolerance my $limit = 16; #call the find subroutine find (\&CheckFile, "/path to your directory"); #subroutine sub CheckFile { $File::Find::name; my $age = -M; #test the age if (-f && ($age > $limit)) { print $File::Find::name; print " is ageing at ",int($age)," days old\n"; rename ( $_, "XYZ.$_;") or die "rename failed: $!"; } else { print $File::Find::name; print " is a youthful ",int($age)," days old\n"; } }
In Section
Seekers of Perl Wisdom
|
|