#!/usr/bin/perl use strict; use warnings; my @strings = qw( QS DD DFD SD QS QS QS DD DFS); my %count; $count{ $_ }++ for @strings; my @sorted = (sort {$count{$a} cmp $count{$b}} keys %count); print pop @sorted, "\n";