#!/usr/local/bin/perl use DBI; &MakeTable; &InsertValues; sub MakeTable() { use DBI; #print "enter username\n"; $dbh = DBI->connect("dbi:mysql:namesdb", 'some' , 'someother',{ AutoCommit => 1, RaiseError => 1}) or die "connection error:$DBI::errstr\n"; $dbh-> do( "create table if not exists names ( #stuff );" ); $dbh-> disconnect; }#sub ends here; sub InsertValues() { $tablename="names"; $infile = '/path/names.dmp'; # $field= "\t|\t"; # field ending syntax from file; $lines="\t|\n";#lines ending syntax from file; $command = qq ~load data infile '$infile' ignore into table $tablename FIELDS terminated by '$field' LINES terminated by '$lines';~; $dbh = DBI->connect("dbi:mysql:namesdb", 'some' , 'someother',{ AutoCommit => 1, RaiseError => 1}) or die "connection error:$DBI::errstr\n"; $dbh->do($command); $dbh-> disconnect; }