tacoking92 has asked for the wisdom of the Perl Monks concerning the following question:
Hi all, first post here. Hopefully someone can help me figure out my little problem I'm fighting with.
I'm attempting to pass an Net::OpenSSH object between subroutines and I'm finding it pretty difficult to do.
Here's what I'm trying.my $ssh = login($user, $pass, $host); test(\$ssh); sub login { ($user, $pass, $host) = @_; my $ssh = Net::OpenSSH -> new($host, user=>$user, password=> $pass); return $ssh; } sub test { $ssh2 = shift; $output = $ssh2 -> capture("ls /tmp"); print $output; }
I get the following error: "Can't call method "capture" on unblessed reference at ./test3.pl"
Is there a way I can pass the object reference between the subroutines?
Thanks for the help.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pass object to subroutine.
by MidLifeXis (Monsignor) on Nov 15, 2011 at 19:01 UTC | |
|
Re: Pass object to subroutine.
by mrstlee (Beadle) on Nov 15, 2011 at 22:09 UTC |