is there a more delicate way to do this? i have a script that uses a subroutine from a module. example
and now there is a module that contains subroutine:"Test.pl" use strict; use DBI; use DB qw(:All); use SQL::Abstract; my $sql = SQL::Abstract->new(); my $dbh = DBI -> connect("dbi:SQLite:dbname=test.db", "", "",{RaiseErr +or=>1, AutoCommit=>1}); my $popsamp = [qw(Popl Samp)]; my $form2 = "ID varchar(40) not null"; createtb($form2,$popsamp,$dbh);
now the problem is that i have to pass $dbh variable to a module to work, but this seams very unprofessional(not that i am one). so i was wondering is there some other way to make variable available to the modules of my interest(specificaly a subroutines in the module)package DB; use strict; use base qw(Exporter); use vars qw(@EXPORT_OK); @EXPORT_OK = qw(createtb); sub createtb{ my ($form, $tabler, $dbh) = @_; my @table = @$tabler; foreach my $table (@table){ my $stm = "create table $table ($form)"; my $stm1 = $dbh -> prepare($stm); $stm1 ->execute; } }
thanx
In reply to Database module question by baxy77bax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |