my ($test, $id, $key)=split /,\s*|\(/, $_, 4; next unless $test=/PROBABLECAUSE\w*/; #### #!/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} #### my ($test, $id, undef, $key)=split /,\s*|\(/, $_, 5; next unless $test=/PROBABLECAUSE\w*/; #### #!/your/perl -w use strict; my($line_count, %dup)=0; while () { my ($test, $id, undef, $key)=split /,\s*|\(/, $_, 5; next unless $test=/PROBABLECAUSE\w*/; # If i may be so bold... $key = lc $key; if (exists $dup{$key}) { print "Duplicates found\n"; print "$dup{$key}->[0]: $dup{$key}->[1]"; print "$line_count: $_"; } else { $dup{$key}=[$line_count, $_]; # store No and line } $line_count++; }