foreach $word ( @theseWords ) { my @lines = split m/ ,/, $Line{$word}; for (@lines){ $sth->execute($word, $_); } }