# Wrote right now, not a copy and paste, so not exact... open(FILE, "/path/to/apd/file.csv") or die "could not open file: $!"; my @_FILE = ; close(FILE); foreach my $_line (@_FILE) { $_line =~ s/\s+//g; my @_fileparts = split(/,/, $_line); my $sth = $dbh->prepare(qq{SELECT * FROM `payouts` WHERE `status` = "Preissue" AND `adp_id` = ?}); $sth->execute($_fileparts[0]); while(my $_pay = $sth->fetchrow_hashref()) { # See this will not work because it may include the one record not included in this file record that I split, so I cannot update this check ID } $sth->finish(); }