use warnings; use strict; my %hash = (CS => 4); while () { chomp; $hash{$_}++; print "$_$hash{$_}\n"; } __DATA__ CS CS #### CS5 CS6