in reply to Unique character in a string?
The thing to consider is that it may be better to trade space for time if you have many such tests on a given string.my $cnt = $str =~ tr/1//;
There are a number of other solutions depending on what your situation is.my %char_cnt; ++$char_cnt{$_} for split //, $str;
Cheers - L~R
|
|---|