☺唐鳳☻
and 1 contributors

NAME

LWP::Simple - simple procedural interface to LWP

SYNOPSIS

  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/")) {
     ...
  }

DESCRIPTION

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.

The following functions are provided (and exported) by this module:

get($url)

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.

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).

head($url)

Get document headers. Depending on the context, head returns the following values:

Boolean Context

The HTTP status code (success/failure) is returned

Numeric Context

The HTTP status code is returned

Item Context

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.

List Context

All headers are returned split into the respective lines.

Hash Context (if it exists?)

A hash is returned mapping the headers. If there are duplicates, the last one wins.

getprint($url)

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.

getstore($url, $file)

Gets a document identified by a URL and stores it in the file. The return value is the HTTP response code.

mirror($url, $file)

Get and store a document identified by a URL, using If-modified-since, and checking the Content-Length. Returns the HTTP response code.

INCOMPATIBLE CHANGES

This Perl 6 version of LWP::Simple does not export the HTTP status codes.
(TODO) This module only supports HTTP as the protocol.
(TODO) This module does not support proxies.

SEE ALSO

LWP, lwpcook, LWP::UserAgent, HTTP::Status, lwp-request, lwp-mirror