in reply to Using variables in require file... not possible?
Inside the Module:my $ProgramDir; BEGIN{ ($ProgramDir) = ( $0=~m|(.+)\/.+$|, $0=~m|(.+)\\.+$| ,"."); } use lib ( $ProgramDir, ); # Current Program's Dir use MyModule ("$ProgramDir/MyModule.db3");
"import" gets called automaticall, on "use".!/usr/bin/perl -w use strict; use warnings; use Class::DBI; package MyModule; our $DBPath="MyModule.db3"; # Default file nme sub import{ my ($class,$newpath)=@_; $DBPath = $newpath || $DBPath; ## print "IMPORT: Setting path to '$DBPath' \n\t \n"; ## Delay this setting till AFTER IMPORT !! MyModule::DBI->connection(qq|dbi:SQLite:dbname=$DBPath|, "", ""); }
"XML is like violence: if it doesn't solve your problem, use more."
|
|---|