Okay, it might be that I am returning in that loop, so the matches aren't being kept! How do I prevent the matches that the condition is true for from getting to @all_matches but reaching @all_pronoun_matches? I have tried removing the "return" and putting the @all_matches push statements in else, of the foreach. This didn't work: It just sorted as if there were no condition statement to separate them. Like everything went into @all_matches For clarity, this is the output I'm looking for:
2 match(es) in which the subject of move is animals :
Section 1_1: Radially symmetrical animals move slowly or not at all .
Section 1_1: Cnidarians also have epithelial cells with muscle fibers whose contractions enable the animals to move , as well as nerve nets that integrate their body activities .
1 match(es) in which the subject of move is cavity :
Section 1_1: Flatworms -LRB- phylum Platyhelminthes -RRB- have no body cavity , lack organs for oxygen transport , have only one entrance to the gut , and move by beating their cilia .
2 match(es) in which the subject of move is they :
Section 1_1: Others , the sea butterflies and heteropods , have a modified foot that functions as a swimming organ with which they move through open ocean waters .
Section 1_1: Because fluids are relatively incompressible , they move to another part of the cavity when muscles surrounding them contract . Even with another heading: "Here are the pronouns:" before "they" shows up. | [reply] [d/l] [select] |
Okay, it might be that I am returning in that loop, so the matches aren't being kept! How do I prevent the matches that the condition is true for from getting to @all_matches but reaching @all_pronoun_matches?
I think you want next or last instead of return. Return exits a subroutine, last exits a loop.
| [reply] |
Here it is, 99% of what you wanted.
The code with my debugging comments (top down chronologically). I merely tweaked it instead of modularizing like I outlined in Re^2: Return 2 arrays, sort the same, and concatenate them, which I would definitely do if this were my project. Heck, I didn't even perltidy until preparing this node.
| [reply] [d/l] [select] |
Ok, I might as well comment on my changes ie your problem
empty return, instead of last, in dependency_checks, made @all_pronoun_matches empty
After that, @all_pronoun_matches wasn't all empty, but still had some empty arrayrefs, which is why I added
and @$matches);
and @$pronoun_matches);
This should have been a change in dependency_checks to return undef instead of an empty ref, but, well, oh well :)
Next I took a look at \%counts, \%pronouncounts and noticed %counts also contained \%pronouncounts -- and the same went for \@all_matches, it also contained \@all_pronoun_matches, so I went back and modified sub dependency_checks and added not $foundPronouns
That got the program 98% there, except there was a missing count number, naturally, since counts no longer contained pronouncounts, so I changed $header, and we're 99% there, the only thing misssing is an extra newline before header :)
Hopefully it makes sense :) | [reply] [d/l] [select] |