#!/usr/bin/perl

##################################################
# Create a user agent object
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$ua->agent("AgentName/0.1 " . $ua->agent);
##################################################
# Create a request
my $req = new HTTP::Request GET => 'http://www.stilen.com/';
$req->content_type('application/x-www-form-urlencoded');
$req->content('match=www&errors=0');
##################################################
# Pass request to the user agent and get a response back
my $res = $ua->request($req);
##################################################
print $res->content;
# Check the outcome of the response
if ($res->is_success) {
  print $res->content;
} else {
      print "Bad luck this time\n";
} 
##################################################
#Notes:  The $ua is created once when the application starts up.  
#        A "User-Agent" header is added and initialized from the $ua->agent attribute before the request is handed to the network layer. 

## FTP request
#$req = HTTP::Request->new(GET => 'ftp://me:passwd@ftp.some.where.com/');
#$req->header(Accept => "text/html, */*;q=0.1"); 
##################################################
##news
#$req = HTTP::Request->new(GET => 'news:abc1234@a.sn.no');

#$req = HTTP::Request->new(POST => 'news:comp.lang.perl.test');
#$req->header(Subject => 'This is a test',
#               From    => 'me@some.where.org');
#$req->content(<<EOT);
#This is the content of the message that we are sending to the world.
#EOT 
##################################################
  
# Get Method 
$req = HTTP::Request->new(GET => 'file:/etc/passwd'); 
##################################################
# Email
$req = HTTP::Request->new(POST => 'mailto:john@stilen.com');
$req->header(Subject => "Test from Perl");
$req->content("Lets see if this worked!\n"); 

##################################################
    
