The loop with early exit looks fine. However if there are large numbers of elements and the range represents a small fraction of the total number of elements, then I'd be inclined to do a binary search for the two end elements in the range and use an array slice to copy the elements in the range out. You may find Binary search helps as a starting point for the search code.
Given two end element indexes the following does the slice and copy:
@arrayA = @{$matches{$element}{$sitekey}}[$first .. $last];
In reply to Re^3: Scoping problems in nested loops
by GrandFather
in thread Scoping problems in nested loops
by mdunnbass
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |