$ua->redirect_ok( $prospective_request, $response ) #### package WWW::Mechanize::AlwaysRedirect; # this class is a subclass of WWW::Mechanize use base 'WWW::Mechanize'; sub redirect_ok { 1; # always return true. } package main; my $agent = WWW::Mechanize::AlwaysRedirect->new(); # proceed as per usual with this $agent instead of the one # in your original code