in reply to number of unique characters in a string

Here is OWTDI - but I bet by the time I finish this post, some other monk will come up with a faster, more Perlish way.

#!/usr/bin/perl -w use strict; print UniqueCount("1234567812") . "\n"; sub UniqueCount { my $string = shift; if ($string) { my %unique; return grep { !$unique{$_}++ } split //, $string; } else { return 0; } }

You will want to modify if you do not want to count spaces or if you want to be case insensitive

Hope this helps - happy hacking - L~R

Update:Dropped un-needed @array in grep