On Tue, Aug 14, 2001 at 06:38:06AM -0700, Vuillemot, Ward W wrote:
> I am receiving the following error:
> Can't call method "func" on an undefined value at
>C:\Inetpub\scripts\convertOptran.pl line 382, line 532.
>
> And the offending line of code is marked by ' <-------------- BAD CODE!
> BAD!'. I checked the passed arguments, which all check out. I do not
> see any errors connecting to the database server, nor installing the
> mysql driver. But the moment I try to see what DBs and tables are
> available, it gives me the offending (and I am very offended) error.
> my $dsn = "DBI:$driver:database=$database;host=$hostname;port=$port";
> eval{ $dbh = DBI->connect($dsn, $user, $password); };
> print $@ if $@;
> eval{ $drh = DBI->install_driver("mysql"); };
> print $@ if $@;
> my @tables;
> eval{ @tables = $dbh->func('_ListTables'); };
><-------------- BAD CODE! BAD!
Your database connection failed, so $dbh contains an undefined value. You
need to check the result of the connect() call.
$dbh = DBI->connect($dsn, $user, $password)
or die "Can't connect: $DBI::errstr\n";
eval { } won't catch errors that aren't thrown.
Ronald