I'd use either LWP::UserAgent, and define a get_basic_credentials method; use LWP::Simple and call $ua->credentials(); read the manual page of wget and detect it has --http-user and --http-passwd options, and it also willing to read a username/password from configuration files; or use WWW::Mechanize and call credentials().