in reply to Re: using modules
in thread using modules
While in db.cgi:package SUBS; use Exporter; @ISA = qw(Exporter); @EXPORT = qw ($log $site $base $dbh); use vars qw ($log $site $base $dbh); sub connectdb() { #Open the Oracle database: my($dbline,@dbinfo); if (!defined(open(DBINFO, "$base/dbinfo"))) { die "Can't open dbinfo.\n"; } while(defined($dbline = <DBINFO>)) { chomp($dbline); push @dbinfo, $dbline; } close(DBINFO); $dbh = DBI->connect($dbinfo[0],$dbinfo[1], $dbinfo[2],$dbinfo[3], { RaiseError => 1, AutoCommit => 1} ); $dbh->trace(2,"$log"); }
The main difference betwee this example and my original post was that I am now using use SUBS as opposed to require SUBS as before. I'm also using 'use var'. SUBS also now exports only those variables used by db.cgi in the @EXPORT array. Again, thanks for all your suggestions.package SUBS; use SUBS; . . . &connect_db();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: using modules
by davorg (Chancellor) on Nov 09, 2001 at 20:35 UTC | |
by maderman (Beadle) on Nov 09, 2001 at 20:44 UTC |