#!perl use strict; use warnings; use Net::Telnet; sub attemptTelnetCheck { my ($host) = @_; my $t = new Net::Telnet( Errmode => 'return', Timeout => 2, Port => 1234 ); my $r = $t->open($host); if (defined $r) { $t->close(); print("$host : SUCCESS!\n"); } else { print("$host : failure. " . $t->errmsg() . "\n"); } } my @hosts = ( "192.168.10.1", "192.168.10.2" ); for my $host (@hosts) { attemptTelnetCheck($host); }