in reply to Authenticating against multiple realms

It's not quite clear what you are trying to do. The credentials of $ua->credentials() are not sent by the code you provide - they don't show up in the POST request packet.

What are 'first' and 'second' realm here, and at which moment what credentials are requested? In what $authinfo and $userid,$password are different, what is the purpose of each?

AFAIK there's only one realm ever associated with a particular URI; if you have two realms to authenticate to, there must be two requests also, but I might be wrong.

If the 'second realm' authentication request is triggered by the handler of the first request, you might have to include the $realm, $userid, $password in $content of the POST.

A bit more explanation about the whole thing would help to help, specially the response of the server with/without Authorization: header line, i.e. status and headers.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}