The so called Basic access authentication is a very simple way to limit access to certain web pages.

Web servers can be configured to protect a given directory, or a whole site by a few lines of configuration. Users are required to authenticate by providing a correct username/password pair which is checked by the web server against a given set of such pairs.

How can we write a script using LWP::UserAgent that will authenticate with such server and will be able to access the protected pages?