$req = $wikiurl."?title=Special:UserLogin&action=submitlogin&type=login&returnto=Main+Page"; print "req = POST $req\n"; $params{'wpLoginAttempt'} = "Log in"; $response = $ua->request( POST $req, Content_Type => 'application/x-www-form-urlencoded' , Content => [ %params ] ); $loggedIn = 0; foreach (keys %{$response->{'_headers'}}) { # print "ServerHeader: ".$_."\n"; if ($_ =~ /^set-cookie$/i) { # server attempting to set a cookie my $a = $response->{'_headers'}->{$_}; if ($a =~ /^ARRAY(.+)$/) { foreach (@{$a}) { print "Server header set-cookie: ======== $_\n"; if (/UserID=\d+\;/i) { $loggedIn = 1; # Success! last; } } } } } print "Login result = $loggedIn\n";