$sth->prepare("INSERT INTO Blah (a,b,c) VALUES (?,?,?)"); tie @list, 'Tie::File', $filename; while (@list) { my @insert = processRow($list[$#list]); #this splits the records into an array and does some data cleaning $sth->execute(@insert); #And check for errors and all that... pop @list; } untie @list; unless ($errors) { unlink $filename; }