The main part of the program builds up 2 LOL (lists of lists, see perldsc). @R contains lists where the 5th element isn't --, and @L contains those where the 5th element IS and 2nd element isn't.
Note that there's no error checking for cases where both the 2nd and 5th elements are --, I don't know if that matters to you.
The 2 LOL's are then passed into the COMPARE routine. By the way, the
use Data::Dumper;looks like a red herring; I don't see anything there that needs that module.
In compare, $L and $R are references to the LOLs built up in the main routine. %L and %R are hashes that map all of the indexes in @$L and @$R respectively to (anything, since the key existence is all that matters), to keep a set of the rows that still need to be processed.
The nested for loops go over every possible combination of items in @$R and @$L, checking if the 4th element in the @$R entry matches the 2nd in @$L. In that case, and if that entry in @$L hasn't already been matched (that's the next unless part), those entries are deleted from %R and %L (so they don't get printed out later), and the "match" line is printed out. The "last;" call ends the $J loop, and moves processing on to the next item in @$R.
After the 2 loops, all the unmatched entries are printed out.
Is it clearer now, or did I make it worse? :)
--
Mike
In reply to Re: Enlightenment
by RMGir
in thread Enlightenment
by johnirl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |