Since you are getting "Use of unitialized value in subtraction" the prime suspect is $ftp->mdtm($_). You say it has a value before but at what point do you check? Are you using the debugger (perl -d) or have you tried to add a warn statement just before that line to print out what this variable holds?