open(ORGDB,"<$database") or die("Error opening database file.\n"); $dbh = DBI->connect( 'dbi:mysql:...', '...', '...', { AutoCommit => 1, PrintError => 0 } ) or die("Unable to connect to database: $DBI::errstr\n"); $sth = $dbh->prepare("INSERT INTO Agents (Name, Phone, Cell, Email) VALUES (?, ?, ?, ?)") or die("Unable to prepare SQL statement: $DBI::errstr\n"); while () { chomp; ($agent_name,$agent_phone,$agent_cell,$agent_email)=split(/\|/); $sth->execute($agent_name, $agent_phone, $agent_cell, $agent_email) or die("Unable to insert record: $DBI::errstr\n"); } close(ORGDB); $sth->finish(); $dbh->disconnect();