in reply to Re: Find duplicate chars in a string
in thread Find duplicate chars in a string
Um... that code doesn't compile, nor does it do the same thing as the original code. This is my version (it could use whatever error checking you might want on the user-supplied alphabet, though):
sub has_dup_letters { local $_ = lc shift; my $alpha = @_ ? shift : 'a-z'; eval "tr/$alpha//cd"; my (%dups, $total); $dups{$_}++ and $total++ for split //; return $total; }
His Royal Cheeziness
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Find duplicate chars in a string
by merlyn (Sage) on Oct 14, 2001 at 19:10 UTC |