http://www.perlmonks.org?node_id=571070


in reply to Testing for port connectivity

I think you mean open (IN, "<hostnames.txt" ) || die "Can't open hostnames.txt";

Try something more like this?

#!/usr/bin/perl -w use strict; use IO::Socket::PortState qw(check_ports); my $proto = 'tcp'; my $port = '23'; my $service = 'telnet port'; my $address = '70.114.230.116'; my $porthash{$proto}->{$port}->{'name'} = $section; check_ports( $address, $ping_timeout, \%porthash ); my $open = $porthash{$proto}->{$port}->{'open'}; if ($open) { print "alive\n"; } else { print "dead\n"; }

Cheers -

Jeffery