stewartski,
Perhaps you should take a look at PerlTidy as good indention really helps in readability and bug hunting. Since you have not shown all of the code, I do not know what $timeThen is so I will assume it is an epoch time stamp. You also do not show where $connect comes from? Are you using warnings and strictures? I have never used Net::FTP, but I would guess it should look something like this.
my $stamp; # set to appropriate epoch time stamp
my @files = $ftp->ls();
chomp( @files );
for my $file ( @files ) {
print "Testing file : $file\n";
if ( $file !~ /\.stm$/ ) {
print "Skipping : $file is not an .stm file\n";
next;
}
my $mtime = $ftp->mdtm($file);
die "cannot get mdtm for $file\n" if ! $mtime;
print "$file last modified : ", scalar localtime($mtime), "\n";
if ( $mtime < $stamp ) {
print "Removing file : $file\n";
$ftp->delete($file);
print $ftp->message, "\n";
}
}
Cheers - L~R |