This is sort of a weird question and it boggles my mind why it's acting like this. There is a site that displays header data like this
Connection: close Date: Tue, 21 Mar 2006 21:10:49 GMT Accept-Ranges: bytes ETag: "8d7ba-16ab-441f261f" Server: Apache/1.3.29 Content-Length: 5803 Content-Type: text/html Content-Type: text/html; charset=iso-8859-1 Last-Modified: Mon, 20 Mar 2006 22:01:03 GMT Client-Date: Tue, 21 Mar 2006 20:54:08 GMT Client-Peer: 66.39.76.93:80 Client-Response-Num: 1 Link: <mailto:cpan@perl.org>; rev="made" Title: CPAN
I want to mimic this the best I can with Perl. LWP::Simple has a head($url) function which I finally got to work (seems as though another module may have been sharing the same head() and it was messing everything up).

Anyway, this is where it's weird.

use strict; use warnings; use LWP::Simple; my $url = "http://www.cpan.org"; my $src = get($url); my @stuff = head($url); print @stuff;
This results in the following
C:\Documents and Settings\admin\Desktop>perl test.pl Use of uninitialized value in print at test.pl line 12. text/html58031142892063Apache/1.3.29
Now when I save it as a scalar, $head = get($url) and do a data dump on it, I get the following.
$VAR1 = bless( { '_protocol' => 'HTTP/1.1', '_content' => '', '_rc' => 200, '_headers' => bless( { 'connection' => 'close', 'client-response-num' => 1, 'last-modified' => 'Mon, 20 Ma +r 2006 22: 01:03 GMT', 'accept-ranges' => 'bytes', 'date' => 'Tue, 21 Mar 2006 21 +:17:28 GMT ', 'client-peer' => '66.39.76.93: +80', 'content-length' => '5803', 'client-date' => 'Tue, 21 Mar +2006 21:17 :43 GMT', 'etag' => '"8d7ba-16ab-441f261 +f"', 'content-type' => 'text/html', 'server' => 'Apache/1.3.29' }, 'HTTP::Headers' ), '_msg' => 'OK', '_request' => bless( { '_content' => '', '_uri' => bless( do{\(my $o = +'http://ww w.cpan.org')}, 'URI::http' ), '_headers' => bless( { 'user-a +gent' => ' LWP::Simple/5.805' }, 'HTTP: +:Headers' ), '_method' => 'HEAD' }, 'HTTP::Request' ) }, 'HTTP::Response' );
It seems to me, there is a TON more information than what I am getting back in my array. My question is, how do I get back all this information? It has things like the IP address and time in here which my @head didn't have. I was told to use UserAgent this afternoon in the CB, but it looks to me that all the information I am looking for is available to me already.

In reply to collecting header data with LWP::Simple by coldfingertips

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.