Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Simple WebServer Scanner

by merlyn (Sage)
on Sep 21, 2001 at 19:09 UTC ( #113895=note: print w/ replies, xml ) Need Help??


in reply to Simple WebServer Scanner

Your perl4-style code ignores the advances made in Perl in the past 8 years. Socket code without "use IO::Socket", and HTTP code without touching the LWP library. Feh!

use LWP; use HTTP::Request::Common; my $response = LWP::UserAgent->new-> simple_request(HEAD "http://perltraining.stonehenge.com"); unless ($response->is_error) { print "server: ", $response->server, "\n"; } else { print "error: ", $response->status_line, "\n"; }

-- Randal L. Schwartz, Perl hacker


Comment on Re: Simple WebServer Scanner
Download Code
Re: Re: Simple WebServer Scanner
by stefp (Vicar) on Sep 21, 2001 at 19:22 UTC
    I am not advocating writing perl4 code but not all programmers have the right of installing new modules on a given site. I don't know for this particular monk though.

    -- stefp

      I already covered this in "No excuses about not using CGI.pm".

      And hosting solutions are a dime-a-dozen these days. Not having basic tools like IO::Socket (which is part of the core distribution) or LWP available to you means you are burning a lot of time needlessly. Move to a different server.

      -- Randal L. Schwartz, Perl hacker

Re: Re: Simple WebServer Scanner
by Asmo (Monk) on Sep 21, 2001 at 19:43 UTC
    sometimes you can't install new modules...
      sometimes you can't install new modules...

      But your script here isn't a CGI script, it is run from the command line. So, if you can install this script, you can also install a module in your home directory.

      sometimes you can't install new modules...

      So I guessed. Sometimes you just have to make the best of a bad situation (here LWP not installable for whatever stupid probably managerial reason). This is also what perl is about. It is a duct tape which can be made to fit in ackward places. Sometimes you may even be obliged to use it stealthily if you want to be able to use it at all. It is ugly but perharps it made your day.

      So I don't understand why merlyn is scornful. You don't always have the choice of using libraries. On the other hand, Asmo, you have a lot of to learn anyway from merlyn.

      -- stefp

Re: Re: Simple WebServer Scanner
by davorg (Chancellor) on Sep 21, 2001 at 19:53 UTC

    You're right about LWP of course and your version is much nicer, but the original script does "use Socket".

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you don't talk about Perl club."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://113895]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2014-04-23 21:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (554 votes), past polls