in reply to my and its use
| Can someone tell me where I am wrong in thinking that I can
| do my $dbh = DBI->connect($db, $user, $auth); ?
| do my $dbh = DBI->connect($db, $user, $auth); ?
There is nothing wrong with your connect statement. However, in your code you are using the $dbh variable before it is properly defined.
Here you use the $dbh handle in the 'else' part of your statement. Think of it as this:my $dbh = DBI->connect($db, $user, $auth) || die $dbh->errstr;
So if the first part fails, it tries the second part, which happens to use the $dbh variable which failed to be defined because the connect call failed.(my $dbh = DBI->connect($db, $user, $auth) ) || ( die $dbh->errstr );
In this case I would put the 'my $dbh' part as a separate stament above the connect statment.
Autark.
In Section
Seekers of Perl Wisdom