#!/use/your/bin/perl -w use strict; my($line_count, @lines, %dup, @capkeys)=0; while () { if (m/PROBABLECAUSE\w*\((\d+),\s*\w*,\s+(\w*)/) { my ($id, $key)= ($1, $2); # check if any key has init caps (not allowed) if ($key =~ m/^[A-Z]\w*/) { push @capkeys, "$line_count: $id - $key\n"; # you may want to fix up caps here before you store # the key so Keysomething matches keysomething } if (exists $dup{$key}) { print "Duplicates found\n"; print "$dup{$key}->[0]: $dup{$key}->[1]\n"; print "$line_count: $_\n"; } else { $dup{$key}=[$line_count, $_]; # store line } $line_count++; } } print "keys with initial caps\n" if @capkeys; foreach (@capkeys) {print}