# untested my $query = qq{ INSERT INTO search VALUES (? ?)}; my $sth = $dbh->prepare($query); # get the list of filenames into an array, or just loop # though them as you wish. This is just an example for my $filename (@files) { local $/ = undef; # will read the file at once open FILE, "< $filename"; my $text = ; close FILE; $sth->execute( $filename, $text); }