in reply to Do I need/want to close __DATA__?

Use warn "xyz\n";. Refer: WARN
warn LIST Prints the value of LIST to STDERR. If the last element of LIST does not end in a newline, it appends the same file/line number text as die does.
Bill

Replies are listed 'Best First'.
Re^2: Do I need/want to close __DATA__?
by soonix (Chancellor) on Apr 13, 2020 at 11:57 UTC
    yes, but shouldn't that append file name and line number where the warn or die statement is, e.g. "example.pl line 2", but definitely not "<DATA> line 290"...
Re^2: Do I need/want to close __DATA__?
by bliako (Abbot) on Apr 13, 2020 at 12:21 UTC

    I use warn because I need that line number (the line 2 and not the <DATA> line 290.. I mean is helpful in knowing what's going on

      warn "xyz at line ", __LINE__, "\n";


      Give a man a fish:  <%-{-{-{-<

      I have problems understanding your problem.

      you said in the OP

      > I don't want to have my scripts mention that someone else's __DATA__ is opened on some line urelated

      • So either the warn is for an end-user, then hide all coordinates by appending "\n"
      • Or it's for you, then ignore the DATA part.
      This might be a little irritating, but IMHO it's a not too tragic side-effect of Perl trying to be explicit.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery