##
my $mech = WWW::Mechanize->new();
my $connected = eval {
$mech->get('does.notexist.example');
1
};
if (! $connected) {
print "Uhoh\n";
};
##
##
use Try::Tiny;
my $mech = WWW::Mechanize->new();
try {
$mech->get('does.notexist.example');
} catch {
print "Uhoh: $_\n";
};