Thursday, 7 October 2010

[perl%dbi] find available drivers

I have found a nice script to find out which are your available DBI drivers, in this page:

http://defindit.com/readme_files/sqlite.html

#!/usr/bin/perl
use DBI;
@driver_names = DBI->available_drivers();
print "driver_names (apparently installed, available):\n";
foreach my $dn (@driver_names)
{
print "$dn\n";
}

I have create a script with it and this is the output:
$ perl find_dbi_drivers_installed.pl
driver_names (apparently installed, available):
DBM
ExampleP
File
Gofer
Proxy
SQLite
Sponge
mysql






EDITED[2010-10-08]:
The previous script is a copy-paste from the web. Obviously I will add the use strict and will go inside a Utils module instead of a script.

For single uses I will use a one-liner as the comments suggest. I like the perl 5.10 one-liner

$ perl -MDBI -E 'say for DBI->available_drivers'

especially the say for...