$cli = new Control::CLI( Use => 'SSH', Timeout => 30, ); $cli->connect( Host => $host, Username => 'abc', Password => 'pass', ); $port = $cli->port; if ( defined($port) ) { print "\tSSH connection to server ($host) established!\n"; } else { print "\tSSH connection to server ($host) could not be established... Exiting program.\n"; exit; }