......................................................................... # check if the first file is still there my $found = grep /\Q$new\E/, $ftp->ls; if ($found) { die "The file is still there !\n" and next; { # send mail if transfer not completed open(MAIL, "|/usr/sbin/sendmail -t") || die "Cant send mail. Reason: $!"; print MAIL "from:$sender\n"; print MAIL "to:$recipient\n"; print MAIL "subject: transfer was not completed !\n"; print MAIL "transfer of second file failed ! \n"; print MAIL "Time: ", scalar localtime, "\n"; close(MAIL); } } #quit FTP when finished $ftp->quit; .........................................................................