I just realized that most strings won't have most characters in them so this can be sped up significantly via:
- tye (but my friends call me "Tye")my $count= 0; for( keys %{ { map {$_,1} unpack "C*", $str } } ){ my $c= pack "C", $_; $count += () = $str =~ /\Q$c\E/g; }
In reply to (tye)Re2: Counting number of characters in a string
by tye
in thread Counting number of characters in a string
by jeffpflueger
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |