Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi,

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

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-19 06:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found