in reply to Re^2: (Perl 5.10.1 or before)What does $_ refer to here?
in thread (Perl 5.10.1 or before)What does $_ refer to here?

Hi

C&P on googling "default variable Perl":

Perl has something similar to the pronoun "it" —a default variable that is the implied target of many operators and built-in functions in Perl. If you do not specify a variable, the functions and operators are executed on the default variable. That variable is $_, and it is the single most important variable in Perl.

So it depends on the last relevant statement.

Because this can get quickly messy with longer code it's good style to avoid it then by using explicit variables.

You could write while ( my $line = <IN> ) { ...

Hope it's clearer now :)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Update

See also Gabor's in depth explanation

https://perlmaven.com/the-default-variable-of-perl