#!/usr/bin/perl use strict; use warnings; use DBI; my $dsn = "DBI:mysql:database=tiet;host=maschine"; my $dbi = DBI->connect($dsn, 'foo', 'bar') or die "Unable to connect to database."; $dbi->do("DELETE FROM tiet_instruments_group"); my $sth = $dbi->prepare("INSERT INTO tiet_instruments_group (group, groupName, instrumentType) VALUES (?, ?, ?)") or die $dbi->errstr; while(my $line = ) { chomp $line; if(my @values = $line =~ m!^(\w+)\s+([\w\s,]+?)\s+(\w+)$!) { print "@values\n"; $sth->execute(@values) or die $dbi->errstr; } } __DATA__ AFR0 Africa, Near East, Turkey EQU AFR1 Africa, Near East, Turkey EQU AGEN Government Agencies BON ASI0 Asia EQU ASI1 Asia EQU ASI2 Asia EQU ASI3 Asia EQU AST0 Austria EQU AST1 Austria EQU