#!/usr/bin/perl -w use strict; use DBI(); my $db_name; my $dbh = DBI->connect("DBI:mysql:database=dbname;host=localhost", "username", "Password", { 'RaiseError' => 1 }); my $sth = $dbh->prepare("SHOW DATABASES"); $sth->execute(); while($db_name = $sth->fetchrow_array( )) { print "$db_name\n"; }