************** file 1 ********************** use strict; use Net::Telnet; sub telnetConnect { my ( $connectionPt, $hostName ) = @_; $connectionPt = Net::Telnet -> new ( Timeout=>6000, Prompt => '/#/'); $connectionPt -> open( $hostName ); $connectionPt -> login ( "root", "password" ); return $connectionPt; }; sub telnetDisconnect { $$_[0] -> close; }; sub xc { my ( $connectionPt, $cmd ) = @_; print "Command: $cmd\n"; $connectionPt -> cmd( "$cmd" ); }; ************ main file *********************** require("../lib/connection.pl") or die "ERROR: cannot open host information file\n"; my $production = "sqa-e450-1"; my $appliance = "sqa-e450-2"; $pro = telnetConnect( $pro, $production ); $app = telnetConnect( $app, $appliance ); my $cmd = "uname -a"; @output = xc( $pro, $cmd ); print " Output1: @output\n"; telnetDisconnect( \$pro ); ********** output ************************* $ perl Perl1.pl Command: uname -a Output1: SunOS sqa-e450-1 5.8 Generic_117350-02 sun4u sparc SUNW,Ultra-4 Can't call method "close" on an undefined value at ../lib/connection.pl line 45.