use strict; my %count; while( ) { chomp; $count{ $_ }++; } print "$_\t$count{ $_ }\n" for keys %count; __DATA__ 123 56 123 56 234 45 123 56 678 93 678 93