Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Foreach loop explanation

by Don Coyote (Pilgrim)
on Nov 23, 2012 at 21:57 UTC ( #1005321=note: print w/ replies, xml ) Need Help??


in reply to Foreach loop explanation

Hello. The reason is because all the lines match from one file to all the other lines in the other file.

If I run your code on two files where some of the lines match and some do not, only the lines that match are printed.

file1 one two three four five six seven eight file2 five six seven eight nine ten eleven twelve prints five six seven eight

update: oh. I didnt think of that SuicideJunkie! if i add a new line between 'three' and 'four' in file one, all the lines are printed out.


Comment on Re: Foreach loop explanation
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (15)
As of 2015-07-07 21:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls