my $temp; eval { $temp = $mech->get($imgsrc); } if ($@) { # alert the error }