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

Reply via email to