in reply to Re^7: nesting loops help?
in thread nesting loops help?
Step 2 looks over every agent in the previous list, and prints every matching line based on the regex, the full line because the full line contains information we need out of schedulesData later. In this example it should return Mindy#mu4, Orlon#mu5, Nancy#mu6, Harry#mu7, Mindy#mu8 because Ted isn't in $agentsData, but the rest are.Harry Mindy Nancy Orlon
Step 3 wants to know if the 5 lines we just found are found in the $schedulesData we're pulling from $schedulesIn file.Ted#mu3 SCRIPTNAME "doit.cmd" DESCRIPTION "mu2" Mindy#mu4 SCRIPTNAME "doit.cmd" DESCRIPTION "mu2" Orlon#mu5 SCRIPTNAME "doit.cmd" DESCRIPTION "SOMETIMES HAS AGENTNAME Orlon" Nancy#mu6 SCRIPTNAME "doit.cmd" DESCRIPTION "mu2" Harry#mu7 SCRIPTNAME "SOMETIMES HAS AGENTNAME Harry" DESCRIPTION "mu2" Mindy#mu8 SCRIPTNAME "doit.cmd" DESCRIPTION "mu2"
Step 4 is the tricky part I've tried a few examples and different ways to explain but thus far am not getting it across. There should be 3 matches in the above, the final step is figuring out what the closest magicName in the file above the matches are. This was the functionality in my second script, my problem was figuring out how to hit on the match and look upward to the previously last match of the other regex while in the previous loop. This is what I meant with $wantedSchedule can't be static, its found by storing all hits on SCHEDULE(.*) to figure out what the magicName is and then using the agent name to determine which one applies to that recordSCHEDULE magicName1 mu1 mu2 Nancy#mu9 mu4 mu2 END SCHEDULE magicName2 mu1 mu2 Mindy#mu4 mu4 mu2 END SCHEDULE magicName3 mu1 mu2 Nancy#mu3 mu4 mu2 END SCHEDULE magicName4 mu1 mu2 Mindy#mu8 mu4 mu2 END
The second column of Yes/No isn't really needed in the final solution, it was used as an intermediary step to get me toward the final solution which turned out to be harder than expected. If its yes it means there will be a record in the last step, if its no then the last step will also be no, but I wanted to start simple by determining first if a match is in the file at all then hit it with a more complex function to find the match and tell me the closest magicName above. magicName is not always the same distance above a match, so there's no good way to figure it out without storing all the magicNames and just printing the last one stored when I reach the input match because the match we search for will always be lower in the record than magicName we actually want to know.Harry#mu7 | No | No Mindy#mu4 | Yes | magicName2 Mindy#mu8 | Yes | magicName4 Nancy#mu6 | No | No Nancy#mu3 | Yes | magicName3 Orlon#mu5 | No | No
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: nesting loops help?
by GrandFather (Saint) on Mar 15, 2022 at 00:02 UTC | |
by shadowfox (Beadle) on Mar 15, 2022 at 02:12 UTC | |
by GrandFather (Saint) on Mar 15, 2022 at 21:13 UTC | |
by eyepopslikeamosquito (Archbishop) on Mar 15, 2022 at 21:48 UTC |