use Modern::Perl; use DBI; my $dbh = DBI->connect( "dbi:SQLite:dbname=c:/data/strawberry-perl/perl/script-chrome/animals.sqlite", "", "" ) or die "Could not open database"; my $statement = q{CREATE TABLE IF NOT EXISTS "main"."sightings" ("id" TEXT PRIMARY KEY NOT NULL, "sampleid" TEXT, "animal" TEXT, "color" TEXT)}; my $rows = $dbh->do($statement) or die $dbh->errstr; $dbh->{AutoCommit} = 0; $dbh->do('BEGIN TRANSACTION'); my $sth = $dbh->prepare( q{INSERT INTO sightings (id, sampleid, animal, color) VALUES (?, ?, ?, ?)}) or die "Could not prepare INSERT statement"; while () { chomp; my ( $id, $sample_id, undef, $animal, undef, $color ) = split /[\t_;]+/; $color ||= 'unknown'; $sth->execute( $id, $sample_id, $animal, $color ); } $dbh->commit;