# enable strict syntax use strict; # load the DBI module (for database connectivity) use DBI; # open connection to database. when you use strict, you # need to declare your variables with 'my'. this a good # thing. trust me. my $dbh = DBI->connect("DBI:mysql:databasename", "user", "password", {RaiseError => 1}); # create a statement handle. the question marks a # placeholders, which simply denote the place you'll # put your data my $sth = $dbh->prepare("INSERT INTO table (column1, column2) VALUES (?, ?)"); open FH, "myfile.txt" or die "Can't open myfile.txt: $!\n"; until ( eof FH ) { my @data; for (1..7) { my $line = ; # slurp in new line chomp; # remove trailing newline character push @data, $line; # add current line to data array } # # do stuff with @data # # actually the data insert into the database $sth->execute( $var1, $var2 ); } close FH; $dbh->disconnect();