Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Extracting common words

by Old_Gray_Bear (Bishop)
on Oct 22, 2015 at 22:41 UTC ( [id://1145700]=note: print w/replies, xml ) Need Help??


in reply to Extracting common words

In Pseudo-Code:
open file1 loop over file 1 extract each $word $results{$word} = 1 end-loop close file1 open file2 loop over file2 extract each $word $results{$word" += 2 #### Note: '+=', not '=' end-loop close file2 ## ### %results contains all of the words in both files. ### Words that appear in both files will have a value of '3'. ### Iterate over the %results keys and print only the ### when the value is '3'. ##

----
I Go Back to Sleep, Now.

OGB

Replies are listed 'Best First'.
Re^2: Extracting common words
by BrowserUk (Patriarch) on Oct 22, 2015 at 23:08 UTC
    ## ### %results contains all of the words in both files. ### Words that appear in both files will have a value of '3'. ### Iterate over the %results keys and print only the ### when the value is '3'. ##

    If a word appears once in the first file and twice in the second, the value will 5; if it appears 3 times in the second file ...


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: Extracting common words
by Anonymous Monk on Oct 22, 2015 at 23:39 UTC
    $results{$word" |= 2 #### Note: '|=', not '+=' and not '='

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-24 21:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found