Ok, I stand corrected, but I never use the two condition conditional. I believe the example presented here would not work, since there is no assignment to $line before the test for "__END__". It could be assigned later, after the test, but that's generally bad practice. Second, the while() will not exit when $exitloop is true since an OR was used.
while(<FH> && !$exitloop ) would work. while(<FH> || $exitloop){ if($line eq "__END__"){ $exitloop = true; } # Do other stuff here... } -----Original Message----- From: Ronald J Kimball [mailto:[EMAIL PROTECTED] Sent: Monday, June 16, 2003 11:27 AM To: Daschbach, John L Cc: Thomas De Groote; Nicholas G. Thornton; [EMAIL PROTECTED] Subject: Re: [MacPerl] exiting a while() loop On Mon, Jun 16, 2003 at 11:19:21AM -0700, Daschbach, John L wrote: > > > > Add an extra variable and set that, like > > > > > > $exitloop = false; > > > while(<FH> || $exitloop){ > > > > What do you suppose happens to the input from <FH> in that line of code? > > It's in $_ as it always is. Ah ha! No, it is not. It is discarded. In the loop: while(<FH> || $exitloop) { } the input read from <FH> is not assigned to $_, because the implicit assignment only happens when the input operator is the only thing in the conditional. perldoc perlop: Ordinarily you must assign the returned value to a vari- able, but there is one situation where an automatic assignment happens. If and only if the input symbol is the only thing inside the conditional of a "while" state- ment (even if disguised as a "for(;;)" loop), the value is automatically assigned to the global variable $_, destroy- ing whatever was there previously. Ronald