program that takes a string as input from user from command line and printing only list of unique characters [closed]
How to parse the string's individual character for eg " =-. lajadsfdddll ooo532333 ksfoiww0etu - " /.> W开发者_C百科#H^*!@#~ nsa@". and add each individual character into hash and then count as ohw many times each character has apeared and the only unique character.
As it sounds very much like a homework question, I'll try pushing you in the right direction. Hopefully you know how to take in a line of user input. In this case, your very general algorithm will look like this:
1. Take the input
2. Parse the input into individual characters - Think about Perl built in methods
3. Add characters to the Hash and count.
4. Iterate through the Hash and print the relevant data.
Character counting is a pretty common problem in a variety of languages, so utilizing Google will be your friend. Also consider that Hashes associate a Key with some value, and only stores unique keys, but it can store any value type.
Additionally, the Perl Cookbook has a recipe on the free online book that discusses how to read individual characters of a string, and this tutorial can be found in a variety different sites.
Long story short, there are plenty of resources out there to answer this problem, and you'll learn more if you go out and find them.
精彩评论