my $fetch; $fetch = sub { # Stop if there are no more URLs return unless my $url = shift @urls; # Fetch the next title my $end = $delay->begin; $ua->get($url => sub { my ($ua, $tx) = @_; say "$url: ", $tx->result->dom->at('title')->text; $end->(); # Next request $fetch->(); }); }; # Process two requests at a time $fetch->() for 1 .. 2; $delay->wait; #### $fetch->(); $delay->wait;