# # # my $input = shift; # my $input = "peon bookkeeper"; my $input; #print $input."\n"; while (<>) { $input = $_; @evenmatches = ($input =~ m/ (.{2}?) (?{ #print $^N . " found at " . ($tmppos = pos($input)) . "\n"; $chars{$^N}++; }) /xg); #print join(", ", @evenmatches)."\n"; #print $#evenmatches + 1 ." matches found\n"; #print $input."\n"; pos($input) = 1; @oddmatches = ($input =~ m/ (.{2}?) (?{ #print $^N . " found at " . ($tmppos = pos($input)) . "\n"; $chars{$^N}++; }) /xg); #print join(", ", @oddmatches)."\n"; #print $#oddmatches + 1 ." matches found\n"; } print "frequency of '$_' is $chars{$_}\n" foreach (sort {$chars{$b} <=> $chars{$a}} keys %chars); print "\n"; print "frequency of '$_' is $chars{$_}\n" foreach (sort keys %chars);