my $sth = $dbh->prepare("INSERT INTO Table1 values (?,?)"); my $newtable = $dbh->prepare("CREATE Table Table2 Column VARCHAR(12)"); while() { ..... .. $sth->execute($words[0],$words[2]) or die $DBI::errstr; $newtable ->execute("SELECT Column2 FROM Table1"); {print "$_";} } $sth->finish(); $newtable->finish(); $dbh->disconnect or warn $dbh->errstr;