in reply to How to do a reciprocal matching statement

What do you think your inner while loop is supposed to do? How many iterations do you think there should be of that loop? Here's how it starts:
while($G2A = $RECI ){
$RECI is a scalar variable containing a string that is all the data read from the file whose name ($a) is the current iterator on the outermost "foreach" loop.

The while statement quoted above simply assigns that same string value to $G2A. There is no "break" or "last" statement inside the loop, and nothing to alter the value of $RECI, so if the string is not empty, the while condition will always be true, and you'll be in an infinite loop. (Did you intend to use "==" instead of "="?)

I second the advice given above: if you still have a problem after fixing that inner while loop, show us a little input data and what the output is supposed to look like for that data.

UPDATE: (Sep. 9): I just happened to take another look at the code (having the perltidy version below really helps!), and I realized a couple more things about your handling of input files:

Replies are listed 'Best First'.
Re^2: How to do a reciprocal matching statement
by ajl412860 (Novice) on Sep 09, 2015 at 19:51 UTC

    To address you post, the reason I am using two different while loops is because this is the only way from what I know, will compare both files that I am looking at. The nested while loops was the only thing that was working. If there is another way of comparing to files in perl, I am open to changing the script to do so.

    The amount of iterations equates to the amount of data within each file, meaning that once every line of each file has been compared to each other, with the appropriate matching statements, then both while loops should stop, and another iteration of the $a from the list should be implicated, thus starting the whole process all over again. The file names from glob function, have a purpose. The gob files contain the names of genome AB files with in the name of the genome BA file name. So when I do the split function on the $a file I will get both file names.

    Also to explain why I did a local $/, without it, the whole content of the files wouldn't be upload into the scripts. At one point only the first lines were being compared, so I used the local $/ so that the scalars could have all the content of the files being upload.

      Regarding your reply, it seems I should have been more clear about the problems in your code:
      1. As written in the OP, your code either never enters the second while loop (because you've read an empty string from an input file) or else it goes into an infinite loop (because if $G2A = $RECI returns true, nothing happens to allow exiting the loop).
      2. As written, your handing of inputs from data files appears to be misguided; it's very unlikely that it can work the way you intend it to work.
      3. Based on your updates to the OP, and your replies to me and other monks, it seems like you don't really have a clear picture of an algorithm that will produce the results you want to get, and so far, we have not gotten from you a clear picture of the inputs and intended outputs.

      I hope you understand what I'm saying. If not, you can ask for clarification.

      But more importantly, see if you can provide a fairly simple, direct description of the task you are trying to accomplish: "(A) There are (how many?) different types of input files - here are brief examples of the content for each type: ... (B) Given these inputs, there's this particular type of match that I need to locate: ... (C) Each time I locate this sort of match, there's this particular information that needs to be output: ...." -- or something to that effect.

      If you can't figure out how to express your task in a simple example, it's much harder for us to help you. But if you can do that, it should help you to get a fresh start on your script. (The OP script is unlikely to be a good starting point.)

      You might like to read How do i extract only contigs of interest, from today. To quote choroba from that thread:

      Searching for information taken from one file in another file is quite + a common task. The usual solution is to hash the identifiers, then i +terate over the second file and check the hash for the existence of t +he identifier.

      The way forward always starts with a minimal test.