I'm not able to close my telnet connection when I use strict. I'm using two files. One file contains the telnet connection routine with "use strict". The other file is the main program. It's giving me an error when I tried to close the connection.
************** 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 inform +ation 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,Ult +ra-4 Can't call method "close" on an undefined value at ../lib/connection.p +l line 45.
Tried passing the variable by reference or no reference didn't work for me. Any idea on what's wrong.
Thanks.

edited: Tue Jul 13 17:39:55 2004 by jeffa - code tags


In reply to How to close a telnet connection when using strict by han_perl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.