... my $content; my $response = $ua->get('http://search.cpan.org/'); if ($response->is_success) { $content = $response->decoded_content; # or whatever } else { warn $response->status_line; } ... #### use threads; ... my $content; my $thread = async{ my $response = $ua->get('http://search.cpan.org/'); if ($response->is_success) { return $response->decoded_content; # or whatever } else { return undef; } }; ... if( $thread->is_joinable() ) { $content = $thread->join; if( $content ) { #do domething with it } else { # notify the failure? } }