in reply to Re^9: Consumes memory then crashs
in thread Consumes memory then crashs
Seems some people need an explanation for why it is dumb.
If you prefer to use an event driven method for performing the OPs task, there is absolutely no logic in installing a 270 module "real time web framework" (nor even a 150+ module POE) to do it.
When LWP::ParallelUA will do the job with just 9 files:
#! perl -slw use strict; use LWP::Parallel::UserAgent; use Time::HiRes qw[ time ]; sub lookup { my( $lookup, $resp, $prot ) = @_; my( $name ) = ${ $resp->{ _request }{ _uri } } =~ m[&user=([^&]+)& +]; print "Response for $name"; if( $lookup =~ m/gain:Overall:\d+:(\d+)/isg ) { print "$name $1"; } elsif( $lookup =~ m/(ERROR)/isg ) { print "$name doesn't exist " } else{ print "$name 0"; } } my @names = do{ local @ARGV = 'firstnames.txt'; <>}; #qw(zezima fred b +ill john jack); chomp @names; my $start = time; my $pua = LWP::Parallel::UserAgent->new(); $pua->timeout( 10 ); $pua->max_req( $ARGV[ 0 ] // 10 ); $pua->register( HTTP::Request->new( 'GET', "http://rscript.org/lookup.php?type=track&time=62899200&user=$ +{_}&skill=all" ), \&lookup ) for @names; my $entries = $pua->wait; warn time - $start; __END__ c:\test>PUA-getnames >nul 91.8953080177307 at C:\test\PUA-getnames.pl line 44, <> line 501. c:\test>PUA-getnames 20 >nul 82.6376140117645 at C:\test\PUA-getnames.pl line 44, <> line 501.
S'no quicker than threads and not that much smaller, but it does at least work!
|
|---|