phramus has asked for the wisdom of the Perl Monks concerning the following question:
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:
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: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).print __LINE__, "\n"; package Args; use v5.10; use strict; use warnings; print __LINE__, "\n";
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Bad line numbers .. bad! (__LINE__)
by toolic (Bishop) on Jul 25, 2013 at 20:09 UTC | |
|
Re: Bad line numbers .. bad!
by Jenda (Abbot) on Jul 25, 2013 at 20:36 UTC | |
by Eily (Monsignor) on Jul 25, 2013 at 21:05 UTC | |
|
Re: Bad line numbers .. bad!
by rjt (Curate) on Jul 25, 2013 at 21:08 UTC | |
by phramus (Novice) on Jul 25, 2013 at 21:42 UTC | |
by AnomalousMonk (Archbishop) on Jul 25, 2013 at 22:25 UTC | |
|
Re: Bad line numbers .. bad!
by mtmcc (Hermit) on Jul 25, 2013 at 20:31 UTC | |
|
Re: Bad line numbers .. bad!
by zork42 (Monk) on Jul 26, 2013 at 01:43 UTC |