Only problem is that you are no longer incrementing counter after you encounter the date.

my $counter = 0; my $dateRX = qr/^$date/; # assuming $date is defined elsewhere while (<LOG>){ last if /$dateRX/; $counter++; } while ( <LOG> ) { print LOGFILE; $counter++; }

UPDATE: I assumed that $counter was actually doing something outside of the context of this code, maybe I should not have assumed that. If the only thing that counter is being used for is to assign the start date variable, then my revision above is un-neccessary. It should also be noted that in the original code, since counter is incremented before the regexp is checked, then the start date variable will always point to the first line AFTER the one that matched.


In reply to Re: Re: Monk Specs.? by ehdonhon
in thread Monk Specs.? by draper7

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.