Try something like this:
#! perl -slw use strict; use threads; use Thread::Queue; use Net::FTP; my $THREADS = 10; my $Q = new Threads::Queue; my @threads = map async { my $ftp = Net::FTP->new("host.com"); $ftp->login('blah','blah'); $ftp->ascii(); while( defined( $_ = $Q->dequeue ) ) { $ftp->put( $_ ); } $ftp->quit(); }, 1 .. $THREADS; my @files = getFiles(); $Q->enqueue( @files ); $Q->engueue( (undef) x $THREADS ); $_->join for @threads;
Start with small values (eg.10) for $THREADS and see how things go. Adjust higher slowly.
In reply to Re: Multiple FTP upload threads with Net::FTP
by BrowserUk
in thread Multiple FTP upload threads with Net::FTP
by rethaew
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |