Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: My Code Is Functional...But Not Tidy :(

by pfaut (Priest)
on Apr 23, 2003 at 17:47 UTC ( [id://252644]=note: print w/replies, xml ) Need Help??


in reply to My Code Is Functional...But Not Tidy :(

Here's how I would do it. YMMV.

#!/usr/bin/perl -w use strict; use IO::Socket::INET; my %services = ( pop => [ 'mail.test.com', 110 ], smtp => [ 'mail.test.com', 25 ], web => [ 'test.com', 80 ], dns => [ 'test.com', 53 ], ); my %status; $status{$_} = 'Up' for keys %services; while (my ($name,$svc) = each %services) { my $sock = IO::Socket::INET->new(Timeout=>1, PeerAddr => $svc->[0], PeerPort => $svc->[1], Proto => 'tcp' ) or $status{$name} = 'Down'; } while (my ($name,$sts) = each %status) { print "$name server is $sts\n"; }
90% of every Perl application is already written.
dragonchild

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-24 12:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found