Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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 ""); unless ($response->is_error) { print "server: ", $response->server, "\n"; } else { print "error: ", $response->status_line, "\n"; }

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
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".


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

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".

      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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://113895]
[Discipulus]: good morning Corion and all monks!!
[Discipulus]: the whole weekend was dedicated to a marionette representation done for all the children of our family / clan and thei friend. 2+ hours divided in three acts + snack time

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2017-03-27 07:19 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (316 votes). Check out past polls.