Listing 1. Reversing a Document

#!/usr/bin/perl -w
use strict;
use diagnostics;
use HTTP::Request;
use HTTP::Response;
use LWP::UserAgent;
# Define the URL
my $url = "http://www.lerner.co.il";
# Create the HTTP request
my $request = new HTTP::Request("GET", $url);
# Create a new useragent
my $ua = new LWP::UserAgent;
# Pass the request to the useragent, and get a
# response
my $response = $ua->request($request);
# If it was successful, print the reversed
# contents
if ($response->is_success)
{
print scalar reverse $response->content, "\n";
}
else
{
print qq{Error retrieving "$url": },
   $response->message;
}