lwilliams has asked for the wisdom of the Perl Monks concerning the following question:

Thanks for the help with checking to see if DBI is installed. Now, i'd like some more specific help: checking to see if a specific DataBase Driver is installed ( like mysql ). Any help would be greatly appreciated!

Replies are listed 'Best First'.
Re: Check for specific DBD
by chromatic (Archbishop) on Sep 02, 2001 at 21:19 UTC
    The available_drivers() class method may be of use. See DBI for more details:
    my $driver = 'mysql'; print "Found $driver!\n" if ( grep { $driver } DBI->available_drivers( +) );
Re: Check for specific DBD
by tachyon (Chancellor) on Sep 02, 2001 at 21:31 UTC

    Just suck it and see I should think

    use DBI; my $dbh = DBI->connect("DBI:CSV:f_dir=/usr/local/whatever") or die "Some sort of problem: " . $DBI::errstr;

    This just checks if DBI can connect via DBD:CSV to a database along the path noted and should fail if the DBD module is absent or the database is not accessible. You get the reason from $DBI::errstr;

    Update

    Of course if I had *read the docs properly* I would have suggested what chromatic did which is a much less agricultural approach.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print