You may have to do this anyway.
In my experience, setting the environment variable with $ENV{SYBASE}='whatever' within a BEGIN block sets it too late, at least when using DBI with DBD::Sybase.
I've had some success with something like this (which, BTW, makes a program nearly impossible to debug)
BEGIN {
#need this so you don't recurse indefinitely:
if ( not exists $ENV{SYBASE_SET} ) {
$ENV{SYBASE_SET} = 1;
$ENV{SYBASE} = 'whatever'; # set the variable
exec $0; # exec self with new env
## NOT_REACHED
}
}
This approach works in cases where the modules one is 'use'ing have their own initialization inside BEGIN blocks.
Edit: You also should make certain that this BEGIN block preceeds any uses or requires which may bring in such modules.
dmm
You can give a man a fish and feed him for a day ...
Or, you can teach him to fish and feed him for a lifetime
|