in reply to Removing duplicates from list

The usual way of removing duplicates from a list is to form a hash. Instead of printing in line 8,     $fnames{$mer} = ''; Then you can extract sort keys %fname to be printed, or for whatever other use you have.

After Compline,
Zaxo