in reply to One loop or two
If your script works well enough as it is, performance-wise, a solution might be quite simple ...
if ($ntid eq $fields[1]) { $matchingbkid = $bkid; last; # END THE LOOP - WE FOUND IT }
The double-loop strategy in this example is retained ... if it works fast enough for your purposes there is no need to redesign it. The difference is that the inner loop starts with the assumption that the key will be NONBKID, then sets about to try to prove otherwise. When the first matching key is discovered, it captures the key then quits looking further. A single output record is generated for either case.
The # COMMENTS are merely for clarity.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: One loop or two
by Anonymous Monk on Aug 01, 2012 at 14:49 UTC |