"Kipp, James" wrote:
> 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.
>
That's about as good as it gets if you use DBD::Informix.
YMMV if you use a different database driver, but probably not by much.
--
Jonathan Leffler ([EMAIL PROTECTED], [EMAIL PROTECTED])
Guardian of DBD::Informix 1.00.PC1 -- see http://www.cpan.org/
#include <disclaimer.h>