Thanks to all for a lot of invaluable knowledge.

In the end, I applied a variation on dws' sliding window technique in "Match in Huge Files." It's proven to completely eliminate the memory usage issue.

The solution (a.k.a. 'The Way Tekkie Did It'):

The addition of the following search subroutine:
sub search { my ($file, $searchString) = @_; local *F; open(F, "<", $file) or return 0; binmode(F); my $nbytes = read(F, my $window, 2 * BLOCKSIZE); while ( $nbytes > 0 ) { if ( $window =~ m/$searchString/ ) { close(F); return 1; } $nbytes = read(F, my $block, BLOCKSIZE); last if $nbytes == 0; substr($window, 0, BLOCKSIZE) = ''; $window .= $block; } close(F); return 0; }

Coupled with a modification to the main loop here:
if(search($file, $searchString)) { print "\tFound: $file\n"; foreach(@dir) { if(/^.*?\s+([A-Z]{1}$numSet\.\S{3})$/) { my $found = join('\\', ($dirPath, $1)); print "\tFound: $found\n"; } } }
And you've got another problem solved by the wisdom of the monks.
Many thanks once more to all who offered their assistance.


In reply to Re: Where's the leak? by tekkie
in thread Where's the leak? by tekkie

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.