in reply to NeverMore

What does upload() return if it fails? You might have to do a dual-part check, if it doesn't return undef or something common like that:
$file2 = upload('T3'); stufferror() unless (defined $file2); # for debugging purposes # print "->$file2<-\n";
BigJoe's idea won't work, I can see that right away. I think he's thinking of something more like: $ftp->upload('T3'); which isn't what you want to do, as you have code elsewhere that does this.