I have 2 functions. in func1 $t->print(); works fine.
but func1 got too long and I created func2 to continue on
$t->print(); statements. but $t->print(); of func2 does not work (perl interpreter
does not know what $t is).
so!, how can I associate $t in func2 to $t in func1,
and continue on $t->print(); statements?
I'm always grateful for your input.
Code follows.
Marco.
sub func1 {
my ($forecast, $t);
use Net::Telnet ();
$t = new Net::Telnet;
$t->open("$ip");
$t->waitfor('/login: /');
$t->print("jeff");
$t->waitfor('/password: *$/i');
$t->print("papa");
$t-> waitfor( '/\-\> *$/i' ) ;
$t-> prompt( '/\-\> *$/i' ) ;
$t->print("pwd");
($forecast) = $t->waitfor('/\->/i');
print $forecast;
#above $t->print("pwd"); works fine and prints the result.
}
sub func2 {
$t->print("ls");
($forecast) = $t->waitfor('/\->/i');
print $forecast;
#this $t->print("ls"); does not work.
#interpreter complains.
}
#End
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com