From what I've found in benchmarks, a positive look-ahead
assertion:
$match =~ /($start .*?) (?=$start)/xs;
is just a HAIR slower than a negative look-ahead assertion:
$match =~ /($start (?: (?! $start ) .)*)/xs;
The first one matches as little from $start as it can until
it's followed by $start again. That would actually FAIL for
the last record. I'd suggest changing it to
$match =~ /($start .*?) (?= $start | \Z)/xs;
Where \Z is the absolute-end-of-string anchor. The second
one matches from $start as much as possible that isn't
$start again.
And I'd like to set the record straight on /s and /m (even
though perlre does a good job). The /s modifier ONLY means
that the . regex character matches EVERY character (including
\n, which it usually doesn't). The /m modifier means that
^ matches the real beginning of a string, or immediately
after a \n, and that $ matches immediately before a newline,
or at the real end of a string. Normally, the ^ anchor only
matches at the REAL beginning of a string, and the $ anchor
only matches the REAL end of a string, or immediately before
a newline at the REAL end of a string. When using /m, the
\A anchor matches the REAL beginning of the string, and the
\Z anchor matches the REAL end of the string.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.