Thanks. That looks really great.

I've been playing with it, and I did hit one snag so far. The arrays sotred in @{$matches{$element}{$sitekey}} contain possibly millions of elements, all stored in numerical order. If we assume that the ones being pushed into @arrayA are going to number a dozen or less, it seems really wasteful to me to sift through the entire array, for instance, once you've already reached values >= $upperlimit.

This is why I had included some of the early loop exits and so on. It will (presumaby) greatly increase the speed of the program, which is highly desirable. What are your thoughts on modifying your code here:

for my $hElem (@{$matches{$element}{$sitekey}}) { print "...in \$hElem\n"; if ($hElem >= $lowerlimit && $hElem <= $upperlimit) { push (@arrayA, $hElem); } }
To something along these lines instead? :

for my $hElem (@{$matches{$element}{$sitekey}}) { next unless ($hElem >= $lowerlimit); break unless ($hElem <= $upperlimit); print "...in \$hElem\n" push (@arrayA, $hElem); }
Thanks,
Matt

In reply to Re^2: Scoping problems in nested loops by mdunnbass
in thread Scoping problems in nested loops by mdunnbass

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.