in reply to Can't call method "errstr" on an undefined value

$dbh = DBI->connect($db_datasource, $db_user_name, $db_password) or die("Could not connect!".$dbh -> errstr);

If the connect call fails then $dbh will be undefined (i.e. it will contain the value "undef") - so trying to call a method on it will be doomed to failure.

In this case you want to access errstr as a package variable.

$dbh = DBI->connect($db_datasource, $db_user_name, $db_password) or die("Could not connect!" . $DBI::errstr);

Update: Maybe you should have tried checking the DBI documentation as the examples for connect show this usage.

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg