hi,

is there a more delicate way to do this? i have a script that uses a subroutine from a module. example

"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);
and now there is a module that contains subroutine:
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; } }
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)

thanx


In reply to Database module question by baxy77bax

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.