Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Perl's __LINE__ off by 2

by Corion (Patriarch)
on Aug 25, 2025 at 10:33 UTC ( [id://11166108]=note: print w/replies, xml ) Need Help??


in reply to Perl's __LINE__ off by 2

If you're using Filter::Simple (or any other kind of source filter), that can easily throw __LINE__ off from what you see in your editor (example).

Another situation where the line numbers deviate from the source code is when you have multiline if statements, but here Perl reports (for example in warnings) the location of the if, not the location where the reason for a warning was encountered.

I'm not aware of other situations where __LINE__ differs from what you see in your text editor, but maybe with creative use of here-docs, you can provoke them.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11166108]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2025-11-16 18:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (72 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.