#!/usr/bin/perl use DBI; my $dbh=DBI->connect("dbi:mysql:database=test;host=myhost;port=3307",'myuser','mypassword') or die "Couldn't connect to database: " . DBI->errstr; while (true) { $dbh->do("drop table if exists t2 like t1") or die "Couldn't drop table t2" . DBI->errstr; $dbh->do("create table if not exists t2 (id int)type=InnoDB") or die "Couldn't create table t2" . DBI->errstr; }