I think the '$dbaccess' in your test.pm should be declared as perl's global var 
as 'our $dbaccess;'  or  'use vars qw($dbaccess);'. Then in your test2.pm,you 
can access it as:

use vars qw($dbaccess);
print $test::dbaccess;

or:
use vars qw($dbaccess);
*dbaccess = \$test::dbaccess;
print $dbaccess;  #the same as 'print $test::dbaccess;'






-----Original Message-----
>From: [EMAIL PROTECTED]
>Sent: Feb 2, 2006 11:50 AM
>To: beginners@perl.org
>Subject: scope of the variable?
>
>Hello All,
>I have following question regarding accessing variable from other module:
>
>In test.pm I have following:
>
>#BEGIN OF THE TEST.PM
>package test;
>
>use strict;
>use warnings;
>
>#
># The object responsible for managing the database connections.
>#
>my $dbaccess = undef;
>
>-somewhere else 
>$dbaccess = new xxxx::xxx::DBAccess( %dbURL);
>
>¡­.
>¡­.
>
>#END OF THE TEST.PM
>
>In test2.pm I have following:
>
>#BEGIN OF THE TEST2.PM
>package test2;
>
>use strict;
>use warnings;
>
>¡­.
>#  How to test::dbaccess ??
>
>#END OF THE TEST2.PM
>
>
>My question is how to access $dbaccess variable (object) defined and 
>initialized in test.pm within test2.pm module?
>
>Thanks,
>Bogumil
>
>-- 
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
><http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>


--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to