in reply to DBI Connect Error Trapping

If I understand correctly, you want to trap DBI connect errors. So, you should eval() the DBI->connect() statement as follows:
... my $dbh; eval { $dbh = DBI->connect(...); }; if ( $@ ) { # do something with the error }
Hope this is what you were asking for!

Replies are listed 'Best First'.
Re: Re: DBI Connect Error Trapping
by hmerrill (Friar) on Nov 08, 2002 at 18:18 UTC
    Shemp is right - the only thing you're missing in your code is the "eval". RaiseError causes dbi statements to *die* when they have an error(so that you don't have to put a "die" with a message along with each dbi statement), and the eval puts the die message into the special $@ variable. So after the eval, you just test the $@ variable - if it has something in it, then something within the eval failed. If you've just got the connect inside the eval, then you know your connect failed. Again, the the error *message* is in the $@(dollar - at-sign) variable.

    Read about RaiseError and "eval" by doing
    perldoc DBI
    at a command prompt

    HTH.