in reply to My Code Is Functional...But Not Tidy :(
#!/usr/local/bin/perl use strict; use warnings; use IO::Socket::INET; my %config = ( 'mail.test.com' => [ 'smtp','pop3' ], 'localhost' => [ 'http','dns' ] ); my %check; foreach my $host (keys %config) { foreach my $port (@{$config{$host}}) { my $host_port = "$host".'_'."_$port"; $check{$host_port} = IO::Socket::INET->new( Timeout => 1, PeerAddr => $host, PeerPort => $port, Proto => 'tcp'); } } foreach my $check_it (keys %check) { if ($check{$check_it}) { print "$check_it is ok\n"; } }
| Mynd you, mønk bites Kan be pretti nasti... |
|
|---|