Much to my chagrin I realized this morning that this notation:

    while(<FILE>) {

evaluates as:

    while(defined($_ = <FILE>)) {

... and NOT as:

    while(defined(local $_ = <FILE>)) {

I had a subroutine that was set up to read and parse a file, but it was
trashing the value of $_ out in the main program!

If I use:

    foreach (<FILE>) {

... it works perfectly (though slurping the whole file right at the start, I
know).

My question is:  why?  Seems like such an easy thing to have done.

TIA.

- Bryan




-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to