in reply to Altering SQL code from Update to Insert

I'd Use a hash to keep track of how many times the appears. A simple regex should be able to extract the field values. Something like
open(FILE, "./logfile.sql"); my %foo; while (<FILE>) { my $index; if (m/Field0=(.*)\;/) { $index = $1; } else { # something didn't match correctly $index =""; } $foo{$index}++; if ($foo{$index} == 1) { # make insert statment } else { # make update statement. } }
Not as neat as ikegami solution but it should work