#Get the input from the user, I have this in a subroutine which is called repeatedly until the user enters 'done' print "Please enter the name of the column, when you are finished type 'done':\n"; chomp(my $column_name=<>); print "Please enter the column type:\n"; chomp (my $column_type=<>); if (defined $fields) { $fields = "$fields, $column_name $column_type"; } else { $fields = "$column_name $column_type"; } #Otherwise $fields begins with ', ' which is not what we want my $create_table = "CREATE TABLE $table_name ($fields)"; #Put this in a variable so that it is all interpolated before being passed to the SQL my $sth=$dbh->do($create_table) or die "Could not prepare table $checktable: $DBI::errstr\n"; print "Table $table_name created\n"