range operator for a condition in 2 steps

Bart Lateur <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Organization MediaMind
Message-ID <[email protected]>
What I would want is to match lines in a loop, one line at a time, say,
between a line cotnaining just "START" and a line containing just "END",
but where the latter condition is only looked at, after an intermediate
condition has been met first. In particular, I have to have seen a blank
line first.

Looking at the skeleton program below, I would like as output to see
these lines printed:

 1) from just underneath "2" till just above "4", blank line under "3"
 2) from just underneath "6" till just above "14", blank line under "11"
(The line just above "9" should be ignored)
 3) from just underneath "17" till just above "20", blank line under
"19"

and that using an expression that works pretty much like the ".." and/or
"..." operators would. You see, I like the layout of the skeleton
program.

I found a working (but quite ugly) solution, but I'll let you people
chew on it first. You'll likely come up with something better, anyway. 

Bart.

Here's the skeleton program:

#!/usr/local/bin/perl
while(<DATA>) {
    if(/^START$/ .. /^END$/) {  # edit this condition
        print;
    }
}
__DATA__
1
2
START
3

END
4
5
6
START
7
8
9
END
10
11

12
13
END
14
15
16
17
START
18
19

END
20
21
22
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.