Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: number of unique characters in a string

by perlguy (Deacon)
on Mar 04, 2003 at 16:12 UTC ( [id://240398]=note: print w/replies, xml ) Need Help??


in reply to number of unique characters in a string

similar to some of the above requests, but how about a quick and easy:
print number_of_uniques('ppppppperlguy') . "\n"; sub number_of_uniques { my %s; return scalar (grep !$s{$_}++, split '', $_[0]); }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://240398]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-19 16:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found