Chapter 17. The LWP Library
LWP, the library for web access in Perl, is a bundle of modules that provide a consistent, object-oriented approach to creating web applications. The library, downloaded as the single file named libwww-perl, contains the following classes:
- File
Parses directory listings.
- Font
Handles Adobe Font Metrics.
- HTML
Parses HTML files and converts them to printable or other forms.
- HTTP
Provides client requests, server responses, and protocol implementation.
- LWP
The core of all web client programs. It creates network connections and manages the communication and transactions between client and server.
- URI
Creates, parses, and translates URLs.
- WWW
Implements standards used for robots (automatic client programs).
Each module provides different building blocks that make up a whole web transaction—from connection, to request, to response and returned data. Each part is encapsulated by an object to give a standard interface to every web program you write. The following section gives an overview of how LWP works to create a web client.
LWP Overview
Any web transaction requires an application that can establish a TCP/IP network connection and send and receive messages using the appropriate protocol (usually HTTP). TCP/IP connections are established using sockets, and messages are exchanged via socket filehandles. See Chapter 13, for information on how to manually create socket applications. LWP provides an object for this application with LWP::UserAgent for clients; HTTP::Daemon ...
Get Perl in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.