I need to have a package level variable. For that I am using the
following method:

package XYZ;

$XYZ::db_initialised = 0;

sub init_db() {
     DB::init() unless $XYZ::db_initialized;
     $XYZ::db_initialized = 1;
}

or

package XYZ;

my $db_initialised = 0;

sub init_db() {
     DB::init() unless $db_initialized;
     $db_initialized = 1;
}

Method 1 works fine and the database is initialized only once
(DB::init() is other module used by me for all db ops)

Method 2 fails and tries to initialize database again...
I can't use method 1 as per company standards... and I can't
understand the reason why method 2 is failing...


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


Reply via email to