#!/usr/local/bin/perl use strict; my %stages; while(<>) { chomp; ++$stages{"$_"}; } my $total; foreach my $key (sort { $stages{$b} <=> $stages{$a} } keys %stages) { my $count = $stages{$key}; if( $count < 0 ) { print "ERROR: count < 0 at key: $key\n"; } printf("%6d - \"%s\"\n", $count, $key); $total += $count; } printf("Total counted: %d\n", $total);