#!/usr/bin/perl use Mojolicious::Lite; my @urls = ( 'https://mojolicious.org', 'https://metacpan.org', 'https://perlmonks.org', 'http://www.google.com', ); my $ua = Mojo::UserAgent->new; my $async = Mojo::IOLoop::Delay->new; $async->steps( sub { my $self = shift; $ua->get($_, $self->begin) for @urls; }, sub { my ($self, @tx) = @_; foreach (@tx) { my $title = ''; my $status = $_->res->is_success ? 'Connected' : $_->error->{message}; if ( $_->res->is_success ) { $title = $_->res->dom->at('title')->text; $title =~ s/^\s+|\s+$//g; # couldn't get Mojo::Util trim function to work } printf("Host: %-20s Status: %-15s Title: %s\n", $_->req->url->host, $status, $title); } } ); $async->wait unless $async->ioloop->is_running;