Hi all, I'm just writing a little POE program as an exercise.

What it does is fetch a list of URLs, keeping 10 threads.

When I run this:

#!/usr/bin/perl -w

use strict;
use POE;
use POE::Component::Client::UserAgent;

my @urls = map { "http://sam.vilain.net/$_"; }
    qw(index.html hobbies.html CV foo bar);

sub _start {
    $_[HEAP]->{alias} = "useragent".$_[ARG0];
    POE::Component::Client::UserAgent->new
        (alias => $_[HEAP]->{alias});
    $_[KERNEL]->yield("next");
}

sub next {
    if (my $url = pop @urls) {
        $_[KERNEL]->post (
            $_[HEAP]->{alias} => "request",
            {
                request => HTTP::Request->new(GET => $url),
                response => $_[SESSION]->postback('next')
            }
        );
    } else {
        $_[KERNEL]->post (
            $_[HEAP]->{alias} => "shutdown",
        );
    }
}

for (1..10) {
    POE::Session -> create
            (
             inline_states => {
                               _start => \&_start,
                               next => \&next,
                              },
             args => [ $_ ],  # arguments
            );
}

$poe_kernel->run();

__END__

I get this:

Odd number of elements in hash assignment at /usr/share/perl5/LWP/UserAgent.pm line 
163.
Use of uninitialized value in list assignment at /usr/share/perl5/LWP/UserAgent.pm 
line 163.

This seems to be being caused by LWP::Parallel::UserAgent::new().  I haven't dug 
deeper than that yet.

Has anyone else run into this before?

Cheers,
Sam.

Reply via email to