Thanks rnewsham. It worked like a champ
Modified code
sub create_database {
print "Please enter the hostname:";
chomp($hostname = <STDIN>);
print "Please enter the name of the new MySQL database:";
chomp($database = <STDIN>);
$dsn = "dbi:$driver::$hostname:$port";
print "Please type the MySQL root username:";
chomp($username = <STDIN>);
print "Please type the MySQL root password:";
chomp($password = <STDIN>);
$dbh = DBI->connect($dsn, $username, $password);
$result = $dbh->do("create database `$database`");
$dbh->do("use `$database`");
if($result) {
say "Database '$database' created successfully";
} else {
say "Database '$database' creation failed";
exit;
}
}
|