sub not500 { my($response, $ua, $handler) = @_; ... } $ua->add_handler("response_done", \¬500 );