#!/usr/bin/perl use strict; use DBI; use utilities; # see below my @cols = qw/ Subject Body FromName FromAddress FromType ToName ToAddress ToType CCName CCAddress CCType BCCName BCCAddress BCCType BillingInformation Categories Importance Mileage Sensitivity /; chdir 'db'; # or wherever you've put the files my %insert; my $dbh = DBI->connect("DBI:mysql:database=jbr", "admin", "1263"); my $csv = DBI->connect("DBI:CSV:") or die "connect" . $DBI::errstr; my $count = 0; for (<*>) { print "\nstarting $_ . . . . "; my $sth = $csv->prepare("SELECT * FROM $_") or die $DBI::errstr; $sth->execute() or die $DBI::errstr; my $n; while (my @ref = $sth->fetchrow_array) { @insert{@cols} = @ref; $n = InsertAndGetID($dbh, 'email', \%insert, 'ID'); } print "done - $n lines so far"; $count = $n; $sth->finish(); } $dbh->disconnect(); $csv->disconnect();