my $dbh = DBI->connect( ... ); # fill in the arguments you need my $sth = $dbh->prepare(<<'SQL'); INSERT INTO ads (lname,fname,item,price,street,city,state,zip) VALUES (?,?,?,?,?,?,?,?) SQL while (my $line = ) { # ... parse $line to get data in @array... you've done this # assuming @array contains 8 values, this inserts the data $sth->execute(@array); }