I second Ovid
's suggestion of using Net::FTP. It's a much more elegant solution.
But in any case, I can't say I know everything there is to know about the mechanics of FTP, but it's my understanding that while port 21 is the port used for making ftp connections, port 20 is the "ftp-data" port, unless you're using PASV mode, which is usually the case when FTPing from behind a firewall, etc. Anyhow, I think
PASV mode allows the data to travel all on one port, rather than two. How you might go about using sockets to receive the data on ftp-data port 20, I'm not really sure.