You could do this which eliminates the need for executing separate append operations for each read:
- Open an ftp connection to the remote server
- Initiate an append operation and open the data connection to the ftp server.
- Start your read loop and write what you read to the data connection. Also perform whatver tracking of the data here.
- When done reading, close the data connection. (Crossing your fingers before closing the connection would be advisable here.)
Basically you would be customizing the
_store_cmd() routine in
Net::FTP with your own process. Sub-classing
Net::FTP actually might not be a half-bad way to do this.
Update: Adding a call-back to Net::FTP for progress tracking shouldn't be too hard. It already prints out hash marks using this code in _store_cmd():
if ($hashh) {
$count += $len;
print $hashh "#" x (int($count / $hashb));
$count %= $hashb;
}
Just replace that with your own code.