in reply to Re^2: flag function
in thread flag function

You are correct!
I typed that in quicky from a cut-n-paste of OP's code without actually running a piece of code.

For those interested, here are some redacted code examples to show what happens:

while (<DATA> and !$flag){print;} error is: Use of uninitialized value $_ in print at C:\testwhile.pl li +ne 8, <DATA> line 1. while ($_=<DATA> and !$flag){print;} error is: Value of <HANDLE> construct can be "0"; test with defined() +at C:\testwhile.pl line 6. while (defined($_=<DATA>) and !$flag) no error
I was impressed the first time that I saw error msg #2! Perl tells you exactly what to do and why. Impressive!
Of course these are examples of why to always use strict; use warnings;!

Update: A recent post my me that demo's this: Re: Search between pattern and append