[EMAIL PROTECTED] wrote:
...
My question is how to access $dbaccess variable (object) defined and
initialized in test.pm within test2.pm module?
If $dbaccess is delared with 'my' in test.pm, you cannot directly access
it from another file. You have two basic options:
1. Provide an accessor function in test.pm that returns the object:
sub dbaccess { $dbaccess }
2. Change the variable to a global (symbol table) variable. You can
optionally use the Exporter module to allow the symbol to be exported to
other namespaces:
Test.pm
-------
package Test;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw($dbaccess);
our $dbaccess;
...
main.pl
-------
use Test qw($dbaccess);
print $dbaccess->some_method;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>