use DBI; # I won't cover the "connect" part -- you'll need to read # docs and try things... but with $odb_handle as the # database connection object: my $sql = "insert into mytable (k,a,b,c) values (?,?,?,?)"; my $sql_handle = $odb_handle->prepare( $sql ); # suppose you're reading rows of space-separated fields # from a data file: while () { @fields = split(/\s/); if ( @fields == 4 ) { $sql_handle->execute( @fields ); } }