I believe you can simply replace:
do { next LINE; print RESULTS "$currentfile"; } until eof();
With print RESULTS <FILE>; because <FILE> will be treated in array context there and grab everything. After that, execution will fall through naturally and when it tries while ($currentfile=<FILE>) { again, it will be at eof so will break out of that loop.

Another approach (basically set a flag for when outputting is ok:
my $matchFound = 0; while ($currentfile=<FILE>) { if( ! $matchFound ){ $matchFound = 1 if $currentfile =~ /^\d{6}/ && $search_date eq sub +str($currentfile,52,10); } next unless $matchFound; print RESULTS $currentfile; }
And yet another way (take advantage of split), though this involves slurping the log which might be bad if it's large (very untested):
my $currentfile = do { local $/ = undef; <FILE> }; my @parts = split /(^\d{6}).{46}$search_date)/m, $s, 2; print RESULTS @parts[1,2] if $parts[1];

In reply to Re: Looping through end of file once a match is found by davidrw
in thread Looping through end of file once a match is found by MBolton

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.