CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner: Problem passing telnet connection to function: Edit Log

New User

Feb 25, 2013, 1:07 AM

Views: 564
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);


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)

Edit Log:
Post edited by DanB (New User) on Feb 25, 2013, 1:12 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives