On Jun 18, Pete Emerson said:
>This isn't successfully going through all of the files. Is the recursion perhaps
>causing problems because DIR keeps getting redefined with each level of
>recursion, or am I missing something else?
Right. The solution is to localize the dirhandle.
>
>sub Purge {
> my ($dir)=@_;
local *DIR;
> opendir(DIR,"$dir") or die "can't read $dir: $!";
> while (defined(my $file = readdir DIR)) {
> next if $file eq '.' or $file eq '..';
> print "Parsing $file\n";
> if ((-M "$dir/$file") > $cutoff) {
> print " Purging $dir/$file\n";
> system("rm -rf $dir/$file");
> } elsif ( -d "$dir/$file" ) {
> print " Recursing into $dir/$file\n";
> &Purge("$dir/$file");
> } else {
> print " Ignoring $dir/$file\n";
> }
> }
> closedir DIR;
>}
>
>
>
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
** Manning Publications, Co, is publishing my Perl Regex book **