Actually, there's no need to write your own parser to get at that URL: LWP::UserAgent, which WWW::Mechanize is an extension of, does it for you!
# UNTESTED; USE AT YOUR OWN PERIL :-)
my $response = $mech->submit_form(
form_name => 'loginForm',
# ...
);
# Follow HTTP or META refreshes.
if (my $url = $response->header('Refresh'))
{
$url =~ s/^\d+;url=//i;
$mech->get($url);
}
There may even be way to get LWP::UA or WWW::Mech to automatically follow along, but I haven't delved into the documentation to see although I did stumble across a WWW::Mechanize wishlist item that you may want to keep your eye on.