Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: unique words

by davido (Cardinal)
on Mar 06, 2015 at 04:46 UTC ( [id://1118979]=note: print w/replies, xml ) Need Help??


in reply to unique words

Everything you need is covered in perlintro (a 30 minute read), and perlfaq4#How can I get the unique keys from two hashes, plus a little imagination.

Here's a basic description:

  1. Declare a hash... maybe call it %words.
  2. Set up an input loop: while(my $line = <> ) { ...
  3. Chomp your input.
  4. Use the input as a hash key: $words{$line}++.
  5. After the loop ends, print the keys of the hash.

Dave

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-25 20:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found