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";
}
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
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...
4 comments:
Or, just:
perl -MDBI -e 'print join("\n", DBI->available_drivers())."\n"'
:-)
Personally I think I'd just say e.g.
perl -MDBI -e 'print join "\n", DBI->available_drivers'
You know you can turn that into a oneliner right?
$ perl -MDBI -E 'say for DBI->available_drivers'
Thanks for the comments about the one-liners.
Post a Comment