Perl usually complains about the line with the actual error, e.g. when a variable is used only once:
use warnings;
if ( 0 ) {
} elsif ( $test ) { } # line 3
# Name "main::test" used only once: possible typo at testt.pl line 3.
This does not work for warnings on use of uninitialized $_:
use warnings;
if ( 0 ) { # line 2
} elsif ( chomp ) { }
# Use of uninitialized value $_ in scalar chomp at testt.pl line 2.
use warnings;
if ( 0 ) { # line 2
} elsif ( m/test/ ) { }
# Use of uninitialized value $_ in pattern match (m//) at testt.pl line 2.
What causes this? When would this behaviour be useful?
perldoc perl5101delta:
Note that this change only affects elsif; you will still see runtime errors/warnings give the beginning or ending line number of the statement instead of the actual line of the offending code: