In the DB module:
In the MAIN code...#!/usr/bin/perl -w use strict; use warnings; use Class::DBI; package AvalancheDB; our $DBPath="avalanchedata.sqlite"; # Default file nme our $DBH; sub import{ my ($class,$newpath)=@_; $DBPath = $newpath || $DBPath; #print "IMPORT: Setting path to '$DBPath' \n\t \n"; ## Delay this setting till AFTER IMPORT !! AvalancheDB::DBI->connection(qq|dbi:SQLite:dbname=$DBPath|, "", "") or die "Cannot connect to Database at $DBPath;"; } ...
Basically, I'm (ab)using the "import" function to get the DB path.... my $ProgramDir; BEGIN{ ($ProgramDir) = ( $0=~m|(.+)\/.+$|, $0=~m|(.+)\\.+$| ,"."); } use lib ( $ProgramDir, ); # Current Program's Dir use AvalancheDB ("$ProgramDir/avalanchedata.sqlite"); ...
Syntactic sugar causes cancer of the semicolon. --Alan Perlis
In reply to Re: Class::DBI and database name
by NetWallah
in thread Class::DBI and database name
by alexbio
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |