in reply to File name compareing
The simplest way would be to count the frequencies of all names and then take the top n of these. Loop over all the names, use each name as a hash key and as the hash value keep a counter of how often you encountered it. The value will be undefined for the first occurrence so the ++ operator correctly assumes zero instead.
my %freqs; $freqs{$_}++ foreach(@filenames);
Then sort by frequency, descending (compare $freqs{$b} with $freqs{$a} instead of the other way round), and take the first say 10:
my @most_frequent = (sort { $freqs{$b} <=> $freqs{$a} } keys %freqs)[0..9];
|
|---|