HTML responses

By Anish on Jul 26, 2009

Good for beginner perl coders for educational purpose. [Comments in snippet are self-explanatory]

#!/usr/local/bin/perl -w        #turn on warnings
use strict;                     #always use
use LWP::UserAgent;             #used for the request
use HTTP::Request::Common;      #used to build request

my ($link,$ua,$req,$results);   #declare variables

$link = shift;                  #grab link from standard input
$ua = LWP::UserAgent->new;      #create new user agent
$req = HTTP::Request->new(HEAD => $link);#grab the header   
$results = $ua->request($req)->as_string; #grab the results
print "$results";               #print the header info

Comments

Sign in to comment.
newklear   -  Aug 08, 2009

Ohh I never knew that.. interesting but yet so simple lol, nicely done :)

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.