in reply to Re: I still can't get only the necessary lines from the file.
in thread I still can't get only the necessary lines from the file.

Oops -my mistake.I have the correct line in my code's unless. \* Exit context \*
The problem is that in print results I get lines that are not between the closest "Start context" and "* end context *".
I suspect that maybe the problem is in this line:
if (/Start context/ .. /\* End Context \*/)
which IMHO takes all the lines between the first "Start context" in the file and last "* end context *"
. Am I right? Or the line:
if (/Start context/ .. /\* End Context \*/)
looks for the closest "Start context" and "* End context *"
Thanks
  • Comment on Re^2: I still can't get only the necessary lines from the file.

Replies are listed 'Best First'.
Re^3: I still can't get only the necessary lines from the file.
by gaal (Parson) on Jul 01, 2004 at 10:00 UTC
    The .. "flip-flop" operator (see perlop) is true "between" the two operands. That is, once the left-hand match is true, the flip-flop is true, until whenever the right-hand match succeeds. Then it's false until the left-hand match is true, and so on.

    So, no: if (/Start context/ .. /\* End Context \*/) { doesn't "take" "all the lines between the first 'Start context' in the file and last '* end context *'", but indeed only those within any of the contexts (and the start marker too, but not the end marker).