#!/usr/bin/perl chomp(@input = ); foreach $key (@input) { $count{$key} += 1; } foreach (sort keys %count) { print "$_: $count{$_}\n"; }