Thanks tye, I used $ftp->code() and get a 553 error which means the file name is not allowed. The file name is "ALL2EXT". It does not have an extension, but I don't think perl cares, and I don't see anything wrong with the file name.
I don't see how "$directory.thedir" could expand to "ALL2EXT". In your example, it would expand to "the directory.thedir", which certainly might not be "allowed". You might want to dump the filename to make sure it is really what you think it is.