On Wed, Jul 16, 2003 at 06:50:21PM +0200, Kevin Pfeiffer wrote:
> I found this in my "to do" directory (was this from perl.beginners - I don't 
> remember and can't find it via Google). I tried the "line-range" operator 
> here, but am wondering if it's possible with it to *not* catch the matching 
> lines (i.e. only lines "3"-"4"). I suppose if you captured into an array 
> then you could just shift and unshift. I also tried a second way below not 
> using range that seems to work well (or?).

There's nothing wrong with the trick you used (and it might be
easier to understand than mine) but you can also switch on the
range operator's return value:

  while (<DATA>) {
    my $range = /line2/../line5/;
    print if $range > 1             # skip the first line
         and $range !~ /E/;         # and the last (which looks like "4E0")
  }

I don't think this is documented (is it?) but it can be handy.

-- 
Steve

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to