LWP::Simple - simple procedural interface to LWP
pugs -MLWP::Simple -e 'getprint "http://www.sn.no"' require LWP::Simple; $content = get("http://www.sn.no/"); die "Couldn't get it!" unless defined $content; if (mirror("http://www.sn.no/", "foo") == ???) { ... } if (getprint("http://www.sn.no/")) { ... }
This module is meant for people who want a simplified view of the libwww-perl library. It should also be suitable for one-liners. If you need more control or access to the header fields in the requests sent and responses received, then you should use the full object-oriented interface provided by the LWP::UserAgent module.
LWP::UserAgent
The following functions are provided (and exported) by this module:
The get() function will fetch the document identified by the given URL and return it. It returns undef if it fails. The $url argument can be either a simple string or a reference to a URI object.
undef
You will not be able to examine the response code or response headers (like 'Content-Type') when you are accessing the web using this function. If you need that information you should use the full OO interface (see LWP::UserAgent).
Get document headers. Depending on the context, head returns the following values:
head
The HTTP status code (success/failure) is returned
The HTTP status code is returned
All headers are returned as one long string, or maybe as a HTTP::Headers object, depending on when want gets implemented. Currently, the headers are returned as one long string.
want
All headers are returned split into the respective lines.
A hash is returned mapping the headers. If there are duplicates, the last one wins.
Get and print a document identified by a URL. The document is printed to the selected default filehandle for output (normally STDOUT) as data is received from the network. If the request fails, then the status code and message are printed on STDERR. The return value is the HTTP response code.
Gets a document identified by a URL and stores it in the file. The return value is the HTTP response code.
Get and store a document identified by a URL, using If-modified-since, and checking the Content-Length. Returns the HTTP response code.
LWP, lwpcook, LWP::UserAgent, HTTP::Status, lwp-request, lwp-mirror
To install Perl6::Pugs, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl6::Pugs
CPAN shell
perl -MCPAN -e shell install Perl6::Pugs
For more information on module installation, please visit the detailed CPAN module installation guide.