Perl implicit close resets $. variable

The documentation for Perl closestates that it $.does not reset if you use an implicit closure done open. I tried to understand what this means, but I could not achieve it. Here is my script:

use strict;
use warnings;
use autodie;
my @files = qw(test1.txt test2.txt test3.txt);

#try with implicit close
for my $file (@files){
    open my $fh, '<', $file;
    while(<$fh>){
        chomp;
        print "line $. is $_\n";
    }
    #implicit close here
}

And here is the contents of all three files that are read:

line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
line 10

Since I am not calling explicitly close, I should use implicit close(I think) and $.should not be reset. However, when I run the script, I get this output showing that $. reset:

line 1 is line 1
line 2 is line 2
line 3 is line 3
line 4 is line 4
line 5 is line 5
line 6 is line 6
line 7 is line 7
line 8 is line 8
line 9 is line 9
line 10 is line 10
line 1 is line 1
line 2 is line 2
line 3 is line 3
line 4 is line 4
line 5 is line 5
line 6 is line 6
line 7 is line 7
line 8 is line 8
line 9 is line 9
line 10 is line 10
line 1 is line 1
line 2 is line 2
line 3 is line 3
line 4 is line 4
line 5 is line 5
line 6 is line 6
line 7 is line 7
line 8 is line 8
line 9 is line 9
line 10 is line 10

It seems to me that this is reset for me. Is my understanding of the documentation unclear? Can someone show me under what circumstances implicit closewill not reset $.?

By the way, I am using Strawberry 5.16.1.

+5
1

$. , read. .

, "" :

my $fh;
for my $file (@files){
    open $fh, '<', $file;
+9

All Articles