in reply to What is this data structure ?

$reqs is a reference to an anonymous array containing freshly made HTTP::Request objects. To do something with one of them, you would do something like:
my $index=2; print "URL of request no. $index is: ".$reqs->[$index]->url();

CU
Robartes-

Replies are listed 'Best First'.
Re: Re: Structure
by Anonymous Monk on Mar 10, 2003 at 11:30 UTC

    Ok cool thanks for that, so what if I add this code

    foreach my $req (@$reqs) { print "Registering '".$req->url."'\n"; if ( my $res = $pua->register ($req) ) { print STDERR $res->error_as_HTML; } } $entries = $pua->wait(); foreach (keys %$entries) { my $res = $entries->{$_}->response; }

    Can someone explain to me what the %entries is all about...?

    I want to loop through the above code lots and lots of time, but I need to clear out the entries hash after each run, how can I do this...?

    undef %entries # or %entries=();

    Doesn't seem to work for me

    Thanks again,
    Tom

      Can someone explain to me what the %entries is all about...?
      There is no hash %entries. There's only a scalar variable named $entries that seems to get back a hashreference as a result of the call $pua->wait() (whatever that is??). Read up on the differences between references and normal data types, e.g. in perldoc perlreftut or the same here online.

      When you say that you want to loop through the above code, what do you mean with above code? All of it? Because I see no reason why you should then need to clear out entries, you are getting back a new one every time out of $pua->wait() ...

      -- Hofmator

        Thanks, i've read the tutorial you told me about and it really helped, I didn't know anything about references, but now I do things are much easier, so thanks, I added the code

        undef %$entries;

        Then ran my program and everything worked ok, the hash reference (or whatever) is cleared out after each loop and all works well! ... so far anyway!