in reply to Warning given, but no line number provided.

warn messages terminating on newline don't show the location.

It's documented and I use that trick regularly to adjust the location.

Update

Hmm ... It seems only to be documented for die

> If the string exception does not end in a newline, the current script line number and input line number (if any) and a newline are appended to it

Cheers Rolf
(addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
Wikisyntax for the Monastery

  • Comment on Re: Warning given, but no line number provided.

Replies are listed 'Best First'.
Re^2: Warning given, but no line number provided.
by syphilis (Archbishop) on Aug 08, 2023 at 15:33 UTC
    It's documented and I use that trick regularly to adjust the location.

    Yes, I use the same trick, too - mainly in test suite scripts when I want to print an informative message (that's not actually a warning) to STDERR.
    In such situations one doesn't want an "at line ..." appendix to appear, and doing warn "message\n" is less typing than print STDERR "message\n".

    But, in this case with the problematic locale, I'm thinking the message is actually intended as a warning - and is enabled by the warnings pragma loaded by POSIX.pm.
    Without the presence of the warnings pragma, that new locale warning won't appear ... and I'm wondering why the line number info is suppressed for this warning, yet every other warning from core perl that's enabled by the warnings pragma provides the additional info (AFAIK). Is it oversight or intentional ?

    Maybe none of this matters - it just struck me as odd that perl would emit this warning (when warnings are enabled), but then withhold the location info.

    UPDATE: As per hv's suggestion below, https://github.com/Perl/perl5/issues/21352 has been created.

    Cheers,
    Rob

      I think it is very likely an oversight - I believe this is part of the ongoing series of improvements to locale handling by Karl Williamson. Please do report it.

        It's still happening on 5.40: Locale 'en_GB' is unsupported, and may hang or crash the interpreter