in reply to file upload

It is not clear whether you're uploading or downloading.
In either case, look Net::FTP. It will save your program from system calls and
you'll be able to create one session for multiple files