#!perl -w use strict; my(@lines,%dup, $id, $key); chomp(@lines=); # read file, put count of key in hash print "Keys with initial caps:\n"; foreach(@lines) { if (m/PROBABLECAUSE\w*\((\d+),\s*\w*,\s+(\w*)/) { ($id, $key)= ($1, $2); $dup{$key} += 1; # check if any key has init caps (not allowed) if ($key =~ m/^[A-Z]\w*/) { print "Id: $id - $key\n"; } } } # check hash for duplicates, if found, display positions in file print "Duplicated keys:\n"; foreach $key (keys %dup) { if ($dup{$key}>1) { print "$key ($dup{$key})\n"; foreach(@lines) { if (m/PROBABLECAUSE\w*\((\d+),\s*\w*,\s+($key),/) { print "Id: $1\n"; } } } }