mvcorrea has asked for the wisdom of the Perl Monks concerning the following question:
I would like to pass the session reference as an function parameter "like code below", but in this situation I am unable to make it right :( And I will love your advices, thanks4all
use Net::Telnet::Cisco; sub doOne{ my $sess = shift; my $cmd = "sh ver"; my @lines = $sess->cmd("$cmd"); foreach my $line (@lines)... # do the parsing return... } my $session = Net::Telnet::Cisco->new( Host => $host, Input_log => $logfile, Timeout => 15, Errmode => "return"); if($session){ $session->login(Name => "$user", Password => "$pass", Timeout => 15) or warn "> \[Login Error\]: $!"; my @arr1 = doOne($session); # session is a hash reference? my @arr1 = doTwo($session); # tried the backslash in front of it $session->close(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: session as function argument in net:telnet:cisco
by Corion (Patriarch) on Nov 16, 2013 at 16:51 UTC | |
by mvcorrea (Novice) on Nov 16, 2013 at 18:29 UTC | |
by AnomalousMonk (Archbishop) on Nov 16, 2013 at 18:39 UTC |