Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I have noticed errors in what perl reports for line numbers, and I'm wondering if some light can be shed here. In one script I'm working with:

package Args; use v5.10; use strict; use warnings; print __LINE__, "\n";
prints 4 for the line number when even I can see that it should print 5. This same script reports 162 for the final line number, when it is actually 181. That's a pretty big error! Moreover, if I add a line to the top of the file:
print __LINE__, "\n"; package Args; use v5.10; use strict; use warnings; print __LINE__, "\n";
it prints 1 and 4 .. the original 4 hasn't changed, and the original 162 at the bottom is still 162. If I add a blank line at the top, though, the subsequent line numbers increment properly (though they're still wrong).

To compound the weirdness, I can copy the lines above and paste them into a new file, which is otherwise empty, and the line numbers are correctly reported, though I suspect errors will creep in if I continue working in that new file. I have noticed similar shenanigans in other scripts I'm working with: The line numbering just gets worse as I go along.

Curiously, a web search doesn't find anyone complaining about this, so I thought I'd come here and ask. I'm using v5.14, the dwimperl release, by the way. Maybe I should update to a later release. Anyway, any wisdom you can offer will be greatly appreciated. Thanks.

In reply to Bad line numbers .. bad! by phramus

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (2)
    As of 2018-05-27 06:30 GMT
    Find Nodes?
      Voting Booth?