use strict; use warnings; use DBI; my $DB = DBI::connect("connect string for your database", "user ID", "password"); # Prepare a statement handle for your inserts my $STH = $DB->prepare("insert into mytable (col1, col2) values (?, ?)"); while () { # Get your data my ($col1, $col2) = parse_line($_); # Now insert it into the database $STH->execute($col1, $col2); }