$dbh->{RaiseError} = 1; my $sql = "INSERT INTO $table(".join(',',@fields).") VALUES(".join(',',(map{'?'}@fields)).")"; my $sth = $dbh->prepare($sql); #line by line from your file while(){ #do your split and execute here. $sth->execute((split /\t/,$_)); }