ukhas jean wrote:
> Hello all ...
>
> I have created a Net::Telnet object (say $t) in my script ... say a.pl
> ... but since the code for "a.pl" is increasing; i decided to created
> "modules" eg. host.pm.
>
> now i want to call this Telnet-object $t in host.pm ... how do i do that??
>
> How can i pass an object like $t from my .pl to .pm file???
> Any pointers are really appreciated.
Once you've included host.pm with a use, you can pass it as an arg to
a sub or use it globally.
our $tobj = new Net::Telnet or die ...
my $ret = host::somesub ($tobj); # pass object into sub in
host.pm
or if you've inported the sub: my $ret = somesub ($tobj);
host.pm subs could access $tobj directly also (less structured) in host.pm.
sub somesub { # access main global $tobj from host.pm
print Data::Dumper->Dump([$main::tobj], [qw($main::tobj)]);
}
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs