
DanB
New User
Feb 25, 2013, 1:07 AM
Views: 723
|
Problem passing telnet connection to function
|
|
|
Hi to everyone and pleased to meet you all! I have a problem passing a telnet connection to sub. I don't have any problem if I create the connection and then use it, like this
my $conn = Net::Telnet->new(Fhopen => $socket); $conn->print($command.(chr 13)); $conn->recv($data, 1024); # OK! but if I try to pass the connection to a subroutine like this
my $conn = GetConnection(...); RunCommand($conn, $command); sub GetConnection { ... my $conn = Net::Telnet->new(Fhopen => $socket); return $conn; } sub RunCommand { my $conn = shift; my $command = shift; $conn->print($command.(chr 13)); $conn->recv($data, 1024); # NOTHING!!!! } it doesn't work: don't do anything. Any ideas? Thank you for support
(This post was edited by DanB on Feb 25, 2013, 1:12 AM)
|