Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 147
  • Last Modified:

determine web server type with HEAD

this is probably a stupid question but here goes:

i know how to do this:

C:\>/perl/bin/head www.website.com

200 OK
Cache-Control: private
Connection: Close
Date: Wed, 26 Feb 2003 01:51:29 GMT
Server: SErver Type here/2.0
Content-Length: 2824
Content-Type: text/html
Client-Date: Wed, 26 Feb 2003 01:51:24 GMT
Client-Response-Num: 1
Set-Cookie: PREF=ID=7804376706b65122:TM=1046224289:LM=1046224289:S=bjrD1brYqRTv
Y7h; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.website.com

but i want to do this in my program and get the same result:

    use LWP:Simple;

    (@stuff) = head($url);

i end up with a very empty array...iam obviously doing something wrong, and i cant find any good documentation on the HEAD method.

any help would be great.....thanx in adv
1 Solution
Code below works on my computer. Try to reinstall LWP if it don't work on yours.

use LWP::Simple;
my ($content_type, $document_length, $modified_time, $expires, $server) = head("http://www.experts-exchange.com");
print "Server is $server\n";
As it says in the LWP::Simple doco


Get document headers. Returns the following 5 values if successful: ($content_type, $document_length, $modified_time, $expires, $server)
Returns an empty list if it fails. In scalar context returns TRUE if successful

You have an empty list, so the head has failed.

real1971Author Commented:
thanx much for the help.......

i was trying to do the head($url) without the "http://"....that was the fix..thanx

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now