In article <567d3a23$0$23845$
e4fe...@news.xs4all.nl>,
Luuk <lu...@invalid.lan> wrote:
>On 25-12-15 06:04, Robert Mesibov wrote:
...
>$
While OP's intent is certainly unclear - it could mean just about anything -
it seems clear based on the choice of "yes" and "no", that the desired
output must be:
yes1
yes2
yes3
The question then is how to get there. So, your solution must be wrong.
I'm not sure about why your program generates "no4", but it seems clear to
me that outputting "no5" /has/ to be wrong.
Now, you can fix the "no5" problem by simplifying your code to:
/START/ { c=1; next }
/FINISH/ { c=0; next }
c
but that still leaves "no4" in the output. It is beginning to look to me
like the answer to OP's question is "no" - that it is not possible to do
this without, in some sense, passing the file multiple times. That is,
either by reading the whole file into memory (as the first responder did),
or by explicitly passing it twice [but see below - *]. There doesn't seem
to be any way to avoid outputting "no4" until you see that there's another
"START" coming up with no intervening "FINISH".
[*] Of course, you probably could avoid reading the whole file either into
memory or twice by setting up a small window that would only buffer up
what's necessary in order to implement the algorithm. Coding this is left
as an exercise for the OP.
--
Ted Cruz sounds like every straight man's first wife.
Ted Cruz is such a closet case his first name should have been Tom.
(Note: The "Ted" moniker is a fictional creation)