#/local/bin/perl -w use DBI; use strict "vars"; #initialize database my $dbh = DBI->connect('dbi:DBM:mldbm=Storable'); $dbh->{RaiseError} = 1; #create table to store data my $sth = $dbh-> prepare("CREATE TABLE hist_mod_score (Index INTEGER, Col1 char(30), Col2 char(7),Col3 char(4) )"); $sth->execute; my $sql = 'INSERT INTO hist_mod_score (Index, Col1, Col2,Col3) VALUES (?,?,?,?)'; $sth = $dbh->prepare($sql) or die $dbh->errstr; # open input file containing raw data open(INPUT, "Input.txt") || die "Can't open input file for reading!:$!\n"; my $index=0; while () { for my $chank (split/\n/) { $chank =~/RegExp to extract data from string/; my $Col1 = $1; my $Col2 = $2; my $Col3 = $3; my @arguments = ($index, $Col1,$Col2,$Col3); # check if regexp works fine print STDERR join("\t",@arguments),"\n"; #parse arguments to a DB $sth->execute(@arguments) or die $sth->errstr; $index++; } } $sth->finish; close (INPUT); # check if all data is parsed correctly $sth = $dbh->prepare(" select * from hist_mod_score "); $sth->execute(); $sth->dump_results if $sth->{NUM_OF_FIELDS};