my ($dirname, $outputfile) = <@ARGV>; #### use strict; use File::Find; die "Usage: $0 startdir, logfile\n" unless ( @ARGV == 2 and -d $ARGV[0] ); open( LOG, ">$ARGV[1]" ) or die "$ARGV[1]: $!\n"; chdir $ARGV[0]; my $age_limit = 30; # maybe take this from @ARGV as well? find( \&log_and_unlink, "." ); sub log_and_unlink { # if ( -l && !-e _ ) { # strike this block ... # print "Stale link: $File::Find::name\n"; # } # elsif # ... (see update paragraph below) if ( -f && -M _ > $age_limit ) { print LOG "deleted $File::Find::name\n"; unlink; } elsif ( -f _ ) { print LOG "kept $File::Find::name (less than $age_limit days old)\n"; } else { print LOG "skipping $File::Find::name (not a data file)\n"; } } # updated to fix indentation: proper indentation IS important.