use warnings; use strict; my $length = 2; my $str = "BEBEBEHUHUHUJJFAFALL"; my %cnt; while ($str =~ /(.{$length})/g) { $cnt{$1}++; } print "Found:\n"; print "$_ $cnt{$_}\n" for sort keys %cnt; __END__ Found: BE 3 FA 2 HU 3 JJ 1 LL 1
In reply to Re: Counting words
by toolic
in thread Counting words
by bisimen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |