use LWP::UserAgent; my (@agents,@routes,@usable); open( AGENTS, "<", "/etc/handler/ua.cfg" ); while( ) { s/#.*//; next if /^(\s)*$/; chomp; push @agents, $_; } close(AGENTS); open( ROUTES, "<", "/etc/handler/routes.cfg" ); while( ) { chomp; s/#.*//; next if /^(\s)*$/; my ( $ip, $port, $login, $password) = split / /, $_ push @routes, "http://$_:$port/,ENABLED"; } close(ROUTES); $ua = LWP::UserAgent->new(); sub makerequest { my($request, $ua, $h) = @_; $request = my while (@routes) { next if m/DISABLED/; push @usable, $_; } my $i = $#agents + 1; $i = rand($i); $i = int $i; my $j = $#usable + 1; $j = rand($j); $j = int $j; $routes[$j] =~ s/\,ENABLED//; $ua->proxy(['http'],$usable[$j]); $h = $ua->proxy_authorization_basic("proxy_user", "proxy_password"); $ua->agent($agents[$i]); $ua->timeout(10); ....................... } $ua->add_handler( prepare_request => \&makerequest) ............