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

Re^4: correspondence between two arrays

by anasuya (Novice)
on Nov 24, 2011 at 10:15 UTC ( #939844=note: print w/ replies, xml ) Need Help??


in reply to Re^3: correspondence between two arrays
in thread correspondence between two arrays

the thing is i want the results with respect to the entries in file1.txt and not the other way around. so if i make the second file as hash, then wont that make the prblem exactly opposite? as for the iteration, i am sorry i think i missed a bracket } there.. sorry for the mistake. Please tell me wat to do.


Comment on Re^4: correspondence between two arrays
Re^5: correspondence between two arrays
by choroba (Abbot) on Nov 24, 2011 at 10:18 UTC
    the thing is i want the results with respect to the entries in file1.txt
    That is exactly what you get if you hash the second file and iterate over the first one.
Re^5: correspondence between two arrays
by aaron_baugher (Deacon) on Nov 24, 2011 at 15:08 UTC

    When you say you need to "check whether a value exists in something," that almost always means you should put something in a hash, and then check your values against that hash. Since you want to check whether values from file1 exist in file2, you put file2 in a hash (with the part you're checking against as the keys), and then start looping through file1 and checking its values to see if they exist as keys in the hash.

    Aaron B.
    My Woefully Neglected Blog, where I occasionally mention Perl.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2014-09-02 03:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (19 votes), past polls