I have code that works, only it sends an end of process file ($vName2) even if no files were sent.
I tried adding a if statement to see if $filefound was equal to 1. That caused the code to fail. I then tried checking if $filefound was greater than 0. That also failed.
Can somebody tell me what I am doing wrong?
Code:
if (-e $vName1)
{
$rc=system("del /Q $vName1");
chdir ($dir);
opendir($dh, $dir) or die "can't opendir $dir: $!";
@files = readdir($dh);
$ftp=Net::FTP->new($host, Debug => 0) or die "No connection";
$ftp->login($username, $password) or die "cannot login", $ftp->message;
$ftp->cwd (Rightfax) or die "can't cwd ", $ftp->message;
$ftp->binary();
for $file (@files)
{
chomp @files;
next if $file =~ /^\.{1,2}$/; # skip file if . or ..
$ftp->put($file) or die "put failed ", $ftp->message;
}
$ftp->quit;
closedir $dh;
$rc=system("del /Q *.pdf");
chdir ($dir2);
opendir($dh, $dir2) or die "can't opendir $dir: $!";
@files = readdir($dh);
$ftp=Net::FTP->new($host, Debug => 0) or die "No connection";
$ftp->login($username, $password) or die "cannot login", $ftp->message;
$ftp->cwd (Rightfax) or die "can't cwd ", $ftp->message;
$ftp->binary();
for $file (@files)
{
chomp @files;
next if $file =~ /^\.{1,2}$/; # skip file if . or ..
$ftp->put($file) or die "put failed ", $ftp->message;
$filefound = 1;
}
$ftp->put($vName2) or die "last put failed", $ftp->message;
$ftp->quit;
closedir $dh;
$rc=system("del /Q *.txt");
}
I tried adding a if statement to see if $filefound was equal to 1. That caused the code to fail. I then tried checking if $filefound was greater than 0. That also failed.
Can somebody tell me what I am doing wrong?