more useful options | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
There are really only two ways of doing this. One is to use two loops. In the first loop, you look for "internal name", then go to your other loop to look for "need this". Becareful to account for not finding "internal name":
The above was written mainly for clarity. You could have used a for loop for the first loop which some people will argue is better because the test is in the outside of the loop instead of being buried in the loop itself. I also didn't test in the second loop to see if I actually found "internal name" (like I said should be done). You could argue that it isn't necessary since the second loop won't execute if the first loop doesn't find "internal name" anyway. However, there may be a difference between not finding "internal name" and finding "internal name" but not finding "need this". I would probably set a flag in the first loop: Of course, if you're setting flags, you might want to do the second solution. It uses only a single loop and uses a flag to see whether you're looking for "internal name" or "need this". I personally like solution #1 because I think it flows better. You're looking for "internal name". Then, when you find it, you look for "needs this". Others will prefer solution #2 because they like the fact that it's a single loop and not two loops. Many people feel that there should only be a single processing loop per "open". All of the replies to this message were really just different takes on one of these two methods. My recommendation is to do which of these two solutions makes the most sense for you, and to keep the code simple and easy for you and your coworkers to follow. Remember that someone down the line is going to have to maintain your code. In reply to Re^3: seek and process from there on
by qazwart
|
|