# require outside the package so that its functions are
# NOT imported into the UtilLib namespace, so that other
# libraries can use them.
require mysql_wrapper_lib.pl;
package UtilLib;
####
# File mysql_wrapper_lib.pl
$foo = 123;
1;
####
package One;
use UtilLib;
package Two;
use UtilLib;
####
# File Mysql_wrapper.pm
package Mysql_wrapper;
use base 'Exporter';
@EXPORT = qw($foo);
$foo = 123;
1;
####
package One;
use Mysql_wrapper;
package Two;
use Mysql_wrapper;
####
package Mysql_wrapper;
$foo = 123;
sub import {
my $pkg = caller;
no strict 'refs';
*{"$pkg\::foo"} = \$foo;
# and the same for other variables...
}
1;