in reply to Document Size

No need to get() the file, then:
($size) = head($url) =~ /^Content-Length:\s+(\d+)/im;

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Re: Document Size
by echo (Pilgrim) on Oct 05, 2001 at 12:19 UTC
    Beware that the Content-Length header is optional though, and many dynamic documents will not output it. Also, some servers tend to do different things with it depending on the request method:

    % HEAD http://www.cnn.com/ 200 OK Cache-Control: private,max-age=60 Connection: close Date: Fri, 05 Oct 2001 08:14:42 GMT Server: Netscape-Enterprise/4.1 Content-Length: 0

    Then there is the case of servers which will not handle HEAD requests. In the end the only guaranteed way is to use GET and length().