CodeJunkie has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
I posted a message about this problem a couple of days ago, but I didn't really include enough detail I guess because I didn't get much of a response. I hope nobody has a problem with me posting about it again. This time i've included the example code i'm running, the URL it falls over when connecting and the error message I am given. The code is taken from the example provided by the author in the download from CPAN.

If anyone can give me any clues about this i'd be grateful.

#!/usr/bin/perl -w require LWP::Parallel::UserAgent; use HTTP::Request; # display tons of debugging messages. See 'perldoc LWP::Debug' #use LWP::Debug qw(+); # shortcut for demo URLs my $url = "http://www.bankerstrust.com/"; my $reqs = [ HTTP::Request->new('GET', $url), ]; my $pua = LWP::Parallel::UserAgent->new(); $pua->in_order (1); # handle requests in order of registration $pua->duplicates(0); # ignore duplicates $pua->timeout (2); # in seconds $pua->redirect (1); # follow redirects foreach my $req (@$reqs) { print "Registering '".$req->url."'\n"; if ( my $res = $pua->register ($req) ) { print STDERR $res->error_as_HTML; } } my $entries = $pua->wait(); foreach (keys %$entries) { my $res = $entries->{$_}->response; print "Answer for '",$res->request->url, "' was \t", $res->code,": " +, $res->message,"\n"; }

When trying to connect to this URL

http://www.bankerstrust.com/

I get this message

Undefined subroutine &LWP::Parallel::UserAgent::_new_response called a +t /usr/lib/perl5/site_perl/5.6.0/LWP/Parallel/UserAgent.pm line 1447.

Many thanks,
Tom

Replies are listed 'Best First'.
Re: Parallel Web Agent Problem
by derby (Abbot) on Mar 11, 2003 at 15:12 UTC
    It's not anything you're doing wrong that I can tell. I'd take this up with the module's author.

    Looking at the code for LWP::Parallel::UserAgent, it is a subclass of LWP::UserAgent. The problematic method (_new_response) is defined in LWP::UserAgent but it is not exported (maybe it is in his version) nor is it an object method (it's a plain old subroutine so calling it by $self->_new_response will not work).

    You could either

    • ask the author about it
    • modify LWP::UserAgent to export the method
    • modify LWP::Parallel::UserAgent to explicity call it (LWP::UserAgent::_new_response)

    My vote would be to contact the author (his contact info is in the documentation), there may be more going on here and I'm missing something.

    -derby

      yeah thanks for that, after looking into the problem myself those are pretty much the conclusions that I came up with as well, I just wanted to be sure I wasn't missing something before going to the author about it. I think you are right and i'll see what he says. Cheers Tom

      I contacted the author and the new version is now available on CPAN which fixes this problem, however he does say that the code is still VERY buggy, so use at own risk!
Re: Parallel Web Agent Problem
by perrin (Chancellor) on Mar 11, 2003 at 16:37 UTC
    You might want to consider forking and using the standard LWP instead. There just aren't that many people actually using this module for production code.
      Which is a pity..

      Makeshifts last the longest.