diff --git a/lib/Mojolicious/Guides/Cookbook.pod b/lib/Mojolicious/Guides/Cookbook.pod index 06880db74c..f30216b865 100644 --- a/lib/Mojolicious/Guides/Cookbook.pod +++ b/lib/Mojolicious/Guides/Cookbook.pod @@ -1413,12 +1413,15 @@ to process requests in smaller batches. # Stop if there are no more URLs return unless my $url = shift @urls; + # Save __SUB__ for later use in another callback + my $fetch = __SUB__; + # Fetch the next title $ua->get($url => sub ($ua, $tx) { say "$url: ", $tx->result->dom->at('title')->text; # Next request - __SUB__->(); + $fetch->(); $promise->resolve if --$count == 0; }); $count++;