On Mon, 26 Feb 2001, Laurie Gennari wrote:
> I'm trying to move oft-used code chunks into modules, and the first one is
> the connection part.
>
> DButils.pm is:
>
> use DBI;
>
> sub dbConnect
> {
> my($database) = shift;
> my($passDir) = shift;
>
> $command = "${pass_dir}/." . $database;
> $password = `$command`;
>
> $dbh = DBI->connect("DBI:Oracle:$database","sys",$password)
> or die("Couldn't connect to $database\n");
> $dbh->{RaiseError} = 1;
> return $dbh;
> }
>
> And I'm calling it from my script as:
>
> #!/usr/local/bin/perl -w
>
> use DButils;
>
> DButils->dbConnect("/export/home/oracle","mymachine_mydb");
>
> I keep getting the error:
>
> DButils.pm did not return a true value at ./ltg.pl line 3.
> BEGIN failed--compilation aborted at ./ltg.pl line 3.
>
> Could someone point me in the right direction?
Yes, it is looking for the ubiquitous 1; at the bottom of your module.
HOWEVER, you are going to get further errors because you are trying to use
the module as if it were a class (i.e., object-oriented style), and you
have not developed it to be a class, and you are trying to dereference a
method that doesn't exist for a class that doesn't exist.
I suggest your read perlmod and perltoot with your favorite POD tool and
study how modules work and how to make them into classes if you want to do
object-oriented programming.
-- Brett
http://www.chapelperilous.net/~bmccoy/
---------------------------------------------------------------------------
If a man has a strong faith he can indulge in the luxury of skepticism.
-- Friedrich Nietzsche