Congratulations on finding one of the oldest recorded Perl bug!
The cause is related to how perl interprets Perl code. The easiest explanation comes from Perlbug ticket #1034 by Ilya Zakharevich.
Diagnostic messages read the line-number-of-currently-executed-chunk-of-code from some memory location. This memory location should be reset when flow of execution winds around. It is reset at the beginning of each statement.
Resetting it more often would slow things down, keeping the
line-number at each opcode would take a lot of memory.