Please refer to the code here...
The variable of interest is scalar(@files) at the end of the foreach. What I am doing here is FTP files contained in the original @files array.
If it failed, then put in @failFs array. At the end of the foreach{}. @files are set to @failFs. I would like a short cut to quite the while loop when no files are left, rather than iterating through the noOfRetry times, but it seems like scalar(@files) is always=1 after the first iteration. Why is that?
Code:
my @failFs={};
#@files, $retruCounter to 3 and $notDone=1 initialised
while ($retryCounter>0 and $notDone==1)
{
print "No of Files to go- " .scalar(@files);
$ftp =Net::FTP->new($host, debug=>1,Passive=>1) or die "couldn't connect";
$ftp->login($userID,$passwd) or die "couldn't login";
foreach $eachRemoteFile(@files)
{
$locFile = File::Spec->catfile($sourceDir,$eachRemoteFile);
$ftp->get($eachRemoteFile,$locFile) or (push @failFs,$eachRemoteFile);
} #end foreach
@files= @failFs; #Files to be retried
logDebug("No of files left-" . scalar(@files));
if (scalar(@files)==1)
{
$notDone=0;
}
$ftp->quit(); ##Quit, retry to get the failed files, if needed
$retryCounter--;
}#end while
The variable of interest is scalar(@files) at the end of the foreach. What I am doing here is FTP files contained in the original @files array.
If it failed, then put in @failFs array. At the end of the foreach{}. @files are set to @failFs. I would like a short cut to quite the while loop when no files are left, rather than iterating through the noOfRetry times, but it seems like scalar(@files) is always=1 after the first iteration. Why is that?