G'day Elliott, welcome to the monestary,
HEAD is useful when you want information about a page, but don't actually want to see the page itself. It's most useful to check if a page exists, or when it was last modified. The biggest users of HEAD requests are proxies, which use HEAD requests to check whether or not they have a current copy of the page in their cache. If the last-modified date returned in the HEAD matches what the proxy has cached, then a whole page lookup is saved.
To access the content-type and get the content at the same time, you'll want to look at using LWP::UserAgent. In particular, the responses you get back from request method are HTTP::Response methods. You can call ->headers or ->headers_as_string to get back the headers (including content-type) as either a HTTP::Headers or as a string respectively.
A bit of sample code may help. This demonstrates how to pull back the frontpage of perlmonks.org, and prints the content type and the content retrieved.
use LWP::UserAgent;
use HTTP::Request::Common;
my $ua = LWP::UserAgent->new;
my $response = $ua->request(GET "http://perlmonks.org/");
print "Content type is ",
$response->headers->header("Content-Type"),
"\n----\nContent is \n",
$response->content;
Cheers,
Paul |