#!/usr/local/bin/perl use strict; use File::Find; #use warnings; # <--- this would have saved the day my $one_month = 'd:/sharedata/perl'; my $one_week = '/ftp/ftp/incoming'; # Traverse desired filesystems my $days = 30; File::Find::find({wanted => \&wanted}, $one_month); my $days = 7; File::Find::find({wanted => \&wanted}, $one_week); sub wanted { /software|patch|files/i and $File::Find::prune = 1; do { print "'$days' Skipping $File::Find::name\n" ; return } if ((-d $_) || (int(-M $_) < $days)); push @deletions, "$File::Find::name"; print "'$days' Deleting: $File::Find::name\n" || die "Can't delete file: $!"; } # notice the lack of a value for $days..... __DATA__ '' Skipping d:/sharedata/perl '' Skipping d:/sharedata/perl/Webmail3 '' Deleting: d:/sharedata/perl/Webmail3/AddresessBookExport Fields.txt '' Deleting: d:/sharedata/perl/Webmail3/config.pl '' Deleting: d:/sharedata/perl/Webmail3/convert.pl # with warnings ............... __DATA__ "my" variable $days masks earlier declaration in same scope at test.pl line 17. Use of uninitialized value in numeric lt (<) at test.pl line 28. "my" variable $days masks earlier declaration in same scope at test.pl line 17. Use of uninitialized value in numeric lt (<) at test.pl line 28. Use of uninitialized value in numeric lt (<) at test.pl line 28. Use of uninitialized value in numeric lt (<) at test.pl line 28. "my" variable $days masks earlier declaration in same scope at test.pl line 17. Use of uninitialized value in numeric lt (<) at test.pl line 28. Use of uninitialized value in numeric lt (<) at test.pl line 28. Use of uninitialized value in numeric lt (<) at test.pl line 28. Use of uninitialized value in numeric lt (<) at test.pl line 28. Use of uninitialized value in numeric lt (<) at test.pl line 28. Use of uninitialized value in numeric lt (<) at test.pl line 28. Use of uninitialized value in numeric lt (<) at test.pl line 28. "my" variable $days masks earlier declaration in same scope at test.pl line 17. Use of uninitialized value in numeric lt (<) at test.pl line 28. Use of uninitialized value in numeric lt (<) at test.pl line 28. Use of uninitialized value in numeric lt (<) at test.pl line 28.