When you find it you have to break out of there. Maybe you left out some
code you thought was obvious but what you are showing me needs a way out.
Label1:
foreach $line1 (@array1){
foreach $line2 (@array2) {
if ($line1 eq $line2) {print ...; next Label1; } # actually you're
not comparing the whole
line
#
but that has nothing to do with the logic
else {next; } # next
Label; goes out of both loops:
} #
next just to next inner loop.
}
I believe that's more or less right, I didn't test it, if fact I knocked it
out in thirty seconds, but the idea of getting out of there when you find
it is right.
ms
At 06:23 6/12/02 -0400, you wrote:
>have you tried the 'eq' function instead of the 'cmp' function in your if
>statement
>
> > -----Original Message-----
> > From: Emerson, Robert D GS09 [mailto:[EMAIL PROTECTED]]
> > Sent: Donnerstag, 6. Juni 2002 15:32
> > To: Perl-Win32-Users (E-mail)
> > Subject: Parse two files for differences.
> >
> >
> > Good Morning,
> > This question may have been answered in the past, but I have not
> > been able to locate an answer. (Probably due to lack of sleep). Anyway, I
>am
> > trying to take two files of different sizes. Both files contain the same
> > information, basically ssn and name. I have tried numerous ways of doing
> > this.
> >
> > For example: I open the files and read them into two arrays. Call
> > them @array1 and @array2. I then do the following:
> >
> > foreach $array1 (@array1)
> > {
> > foreach $array2 (@array2)
> > {
> > if (substr($array1,0,11) cmp substr($array2,0,11) {
> > print OUT $FileOut; }
> > }
> > }
> >
> > I am comparing only strings (ssn value) in each. If they are equal
> > than it prints out. Otherwise I don't care. Now the problem I have is that
> > it does print out, but it prints many, many, many things. I can take two
> > files that are both under 3K in size and create an output file of 33Meg in
> > size. The first array is the smaller one. The second array is the larger
> > one. If this problem places me on the Doh! list, so be it. I have lost
>many
> > hours of sleep trying to find it and that may be my only mistake. I thank
> > everyone in advance for looking at this.
> >
> > V/R,
> > Robert Emerson, MCSE, MCP+Internet KF4KHW
> > Information Technologist - GS09
> > POC: CHCS/ADS/PHCA/Modern/Exchange Server/FastData/NT System
> > Administrator/Network Support/Remedy Naval Hospital Cherry Point PSC Box
> > 8023 Cherry Point, North Carolina 28533
> > Office: (252) 466-0549 comm
> > 582-0549 DSN
> > (252) 466-0553 fax comm
> > 582-0553 fax DSN
> >
> > E-mail: [EMAIL PROTECTED] (work)
> > [EMAIL PROTECTED] (home)
> >
> > "Out the 10BaseT, through the router, down the T1, over the leased line,
> > off the bridge, past the firewall,.....nothing but net."
> > Author Unknown
> >
> >
> >
> > <<Emerson, Robert D GS09.vcf>>
> > _______________________________________________
> > Perl-Win32-Users mailing list
> > [EMAIL PROTECTED]
> > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> >
>_______________________________________________
>Perl-Win32-Users mailing list
>[EMAIL PROTECTED]
>To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs