This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
warnings: Omit handle when $. is 0
authorSlaven Rezić <slaven@rezic.de>
Sun, 11 Feb 2018 20:36:07 +0000 (12:36 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 11 Feb 2018 20:40:36 +0000 (12:40 -0800)
otherwise the new _at_level functions end up including
‘at <handle> line 0’.

[Commit message by the committer.]

lib/warnings.pm
regen/warnings.pl

index ea88daf..911c5aa 100644 (file)
@@ -448,7 +448,7 @@ sub __chk
     # If we have an explicit level, bypass Carp.
     if ($has_level and @callers_bitmask) {
        my $stuff = " at " . join " line ", (caller $i)[1,2];
-       $stuff .= ", <" . *${^LAST_FH}{NAME} . "> line $." if ${^LAST_FH};
+       $stuff .= ", <" . *${^LAST_FH}{NAME} . "> line $." if $. && ${^LAST_FH};
        die "$message$stuff.\n" if $results[0];
        return warn "$message$stuff.\n";
     }
index a94a752..ef2d169 100644 (file)
@@ -765,7 +765,7 @@ sub __chk
     # If we have an explicit level, bypass Carp.
     if ($has_level and @callers_bitmask) {
        my $stuff = " at " . join " line ", (caller $i)[1,2];
-       $stuff .= ", <" . *${^LAST_FH}{NAME} . "> line $." if ${^LAST_FH};
+       $stuff .= ", <" . *${^LAST_FH}{NAME} . "> line $." if $. && ${^LAST_FH};
        die "$message$stuff.\n" if $results[0];
        return warn "$message$stuff.\n";
     }