Jason Forget
unread,Jul 20, 2011, 10:34:16 AM7/20/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nzbperl
Hello all,
I am receive the unintialized value in number lt (<) at error when
running the below perl script. The error is indicated on line 34.
The challenge I face is that this script was written by one person;
modified by another and I am tasked to fix it. I am a beginner to
perl scripting. From what I've read, the (<) needs to be
initialized...???
The script is called to delete files from a directory beyond a certain
date.
#!\Perl\bin\perl -w
# usage: DeleteFiles.pl <dir> <#days>
#use strict;
# sub recurse($) {
sub recurse {
# my($path) = @_;
my($path) = $_[0];
my($days) = $_[1];
my($seconds) = $days*24*60*60;
## append a trailing / if it's not there
$path .= '\\' if($path !~ /\/$/);
print "Set to delete from ... $path\n";
##$path = '\\Working_Temp\\';
##print "Hard coded to delete from: $path\n";
## print the directory being searched
##print $path,"\n";
open (MYFILE, '>>deletes.bat');
## loop through the files contained in the directory
for my $eachFile (glob($path.'*')) {
## if the file is a directory
if( -d $eachFile) {
## pass the directory to the routine ( recursion )
print "recursing $eachFile\n";
recurse($eachFile, $days);
} else {
## print the file ... tabbed for readability
my $now = time;
my @stat = stat("$eachFile");
if ($stat[9] < ($now - $seconds))
{
#print "del $eachFile\n";
print MYFILE "del \"$eachFile\"\n";
unlink("$eachFile");
print "Done.\n";
} print "\t",$eachFile,"\n";
}
}
}
## initial call ... $ARGV[0] is the first command line argument
recurse($ARGV[0], $ARGV[1]);
#close (MYFILE);