in reply to RE: Re: LWP::Simple
in thread LWP::Simple, a bug in head() function?

Is not just from expires field, also when content_length and modified_time are missing the result are "corrupted".
Please take a more carefully look at the run output that i posted:
The idea is to obtain something like:

content_type <> content_length <> last_modified <> expires <> server

and i never obtained server as last field (after last <> separator),
the position of server was 3 and, respectively, 4 (never 5 :()(indexing
from 1)

All that three requested urls has no expires, and first
was a directory listing (meaning no content_length and modified_time)

Thanks.

Replies are listed 'Best First'.
Re: RE: RE: Re: LWP::Simple
by LucidMatrix (Initiate) on Feb 13, 2001 at 13:20 UTC
    I'm working on a similer project and I get no errors
    on this, I'm not sure why its not working for you.
    I've formated the code a bit differtly, but nothing
    has changed really.


    #!/usr/bin/perl -w #url_touch.pl program file use strict; use LWP::Simple; my $url = $ARGV[0]; my $url_head; my @list; foreach $url_head(head($url)) { $url_head = "Not Given" unless defined $url_head; push( @list, $url_head); } my ($content_type, $document_length, $modified_time, $expires, $server +) = @list; print ">>$content_type<< "; print ">>$document_length<< "; print ">>$modified_time<< "; print ">>$expires<< "; print ">>$server<<\n";
    --- END_OF_FILE


    I do know that you have to use a fully qualifed URL for this to work

    work.

    www.webadept.net/index.html

    won't work, I have to use the
    http://www.webadept.net/index.html for it to work.
    here is the command and output...

    tigger$ perl url_touch.pl http://www.cjsportscards.com/index.html


    >>text/html<< >>13168<< >>982047528<< >>Not Given<< >> ConcentricHost-Ashurbanipal/2.0 (XO(TM) Web Site Hosting)<<

    Hope this helps..

    Glenn Hefley
    www.lucidmatrix.com
RE: RE: RE: Re: LWP::Simple
by plaid (Chaplain) on Mar 15, 2000 at 06:02 UTC
    The last modified time is calculated from the same str2time function that the expires time is. Changing the one line inside Date.pm should fix both of those problems. The missing content length on the first test of yours doesn't seem to be a problem, as it's undef when there isn't one.