Input file: 0011 Sally 1122 Brandon 2233 George 0011 Roy 1122 Simson #### Output: 0011 ---> 2 Sally Roy 1122 ---> 2 Brandon Simson 2233 ---> 1 George. #### my %count; my $file = "Input file"; open my $fh, '<', $file or die "Could not open '$file' $!"; while (my $line = <$fh>) { foreach my $str ($line) { $count{$str}++; } } foreach my $str (sort keys %count) { printf "%-31s %s\n", $str, $count{$str}; }