How can I match variable length data between /FIRST/ .. /LAST/ (without including FIRST and LAST.
Well at first sight I can imagine two methods.
  1. Check the value of this expression. It's not just a boolean, it has a special format: it returns the sequence number of how many times in a row it has returned true. Also, the last value is special, as it has "E0" appended. That doesn't change the numerical value, "5E0" is as much a valid format for the number 5, as "5" is. For example:
    for ('A' .. 'Z') { if(my $counter = ($_ eq 'F' .. $_ eq 'J')) { print "$counter: $_\n"; } }
    which prints:
    1: F
    2: G
    3: H
    4: I
    5E0: J
    
    As you can see, extracting the first (numerical 1) and last (string ends in "E0") time it'll match is easily recognized
  2. A second method is to have a flag for the first and second match:
    for ('A' .. 'Z') { if((my $first = $_ eq 'F') .. (my $last = $_ eq 'J')) { printf "%s first:%s last:%s\n", $_, $first?'yes':'no', $last?' +yes':'no', ; } }
    which prints:
    F first:yes last:no
    G first:no last:no
    H first:no last:no
    I first:no last:no
    J first:no last:yes
    
Also what is the difference between ".." and "..."?
Well... in some cases it is possible that the first and the last condition are both met on the first item. Sometimes you want to include that, in that case, use "..". Sometimes you want to skip it, for example if you want to match stuff between two identical delimiters. In the latter case, use "...", which skips the second test if you're on the first match — your "START".

A demonstration of the difference: the next code takes a range between two numbers that are divisible by 3, in the sequence 1 .. 8


In reply to Re: Select data between a START and END pattern by bart
in thread Select data between a START and END pattern by Anonymous Monk

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.