a_mere_kat has asked for the wisdom of the Perl Monks concerning the following question:


I have a problem with my "fruity loops" they are not so fruity and sadly seem to loop forever.

I am having some problems embedding loops. I get this problem continuously and I don't know why.

Ok here is the problem I need to compare selected fields from two flat files.

I have extracted the one field I want from each line of the two files and placed it into two arrays.

Then using an if statement inside a for loop embedded in another for loop. This set up should compare each element of one array to every element of another array. The results being output to two flat files. respectivly matches and non matches. Instead of producing what I want it to it just goes into an infinite loop. I want to know why this occurs and how I can get over this problem? If anyone sends me a RTFM advisory they can stuff my output in there I/O and die. I am posting this because I would like help not abuse please.

Below is the code I have written to perform the task Feeble as it may be it should do the job. Would someone out there please be kind enough to point out what may be obvious to them but is sadly not obvious to freshmeat like me. Thankyou for your time.
for ( $i = 1 ; $i <= $#line ; $i++ ) { $k = $line[$i]; for ( $v = 1 ; $v <= $#angel ; $v++ ) { $j = $angel[$v]; if ( $k =~ m/($j)/i ) { push ( @a, $v ); } else { push ( @b, $v ); } } }

update (broquaint): added <code> tags