Hi
I slurped a data file into an array and I know there are many ways of
inserting the fields into a table. I was just wondering what the most
efficient way would be.
Here are the relevent code snippets.
--
my $id, $fname, $lname, $phone, $deptid, @table;
my $file = "c:\\test\\people.csv";
open(FILE, "<$file") or die "can't open file: $!";
while (<FILE>) {
@table = split(/,/ , $file );
--
my $sth = $dbh->prepare( "INSERT INTO tbl_people VALUES (?,?,?,?,?)" );
foreach (@table){
($id, $fname, $lname, $phone, $deptid) = split;
$sth->execute($id, $fname, $lname, $phone, $deptid);
}
--
or should I us a do() or something else.
Thanks for any help
Jim