|
|
| laziness, impatience, and hubris | |
| PerlMonks |
Re: File handles in regular expressionsby Kenosis (Deacon) |
| on Oct 19, 2012 at 07:04 UTC ( #999876=note: print w/ replies, xml ) | Need Help?? |
|
Hi, Vikas, and welcome to PerlMonks! You've enclosed one loop within another, so you're attempting to compare the first $comp1 value against all elements of @var2, and so on. And tobyink's point about "if they match" is well made, so I suspect you want $comp1 eq $comp2. Given this, consider the following:
If a line in @file1Lines is found in @file2Lines via the smart match operator (works as equality), it's added to the hash %matchingLines for later printing to a file (the hash is used to avoid the possibility of writing multiple instances of the same line to the file). Hope this helps! Update: Lotus1 correctly brought to my attention that I misunderstood the OP. Have revised the script.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||