Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Getting file and line number where a subroutine is declared

by brian_d_foy (Abbot)
on Feb 02, 2009 at 16:41 UTC ( #740741=note: print w/replies, xml ) Need Help??


in reply to Getting file and line number where a subroutine is declared

Have you seen Track the filename/line number of an anonymous coderef?

--
brian d foy <brian@stonehenge.com>
Subscribe to The Perl Review
  • Comment on Re: Getting file and line number where a subroutine is declared

Replies are listed 'Best First'.
Re^2: Getting file and line number where a subroutine is declared
by Ovid (Cardinal) on Feb 02, 2009 at 17:31 UTC

    The problem with those, I think, is the problem I had above. They won't work if the code is declared after I try to inspect it because GV->LINE apparently reports the first glob entry ... and that's created when I take the reference.

    On P5P, Rafael suggested I use START->line instead. It returns the line number of the first expression encountered in the sub. Not perfect, but close enough to what I want (I also encountered GV->LINE returning the line number of the closing curly brace in the sub. Much worse than START.

      They won't work if the code is declared after I try to inspect it

      You seem to be confusing function declaration and function definition. You are getting is the line number of the declaration. What you want to line number of the definition.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://740741]
help
Chatterbox?
[stevieb]: Obviously, Travis CI just won't cut it for these distributions...
[stevieb]: I went on my merry way writing a cross-platform, network-aware system that works across Perlbrew and Berrybrew systems and runs unit tests for Perl dists on all installed versions, with the ability to manage *brew commands themselves
[stevieb]: That worked out exceptionally well, as when I started that project, I hadn't delved into hardware development yet.
[stevieb]: found a issue in MetaCPAN::Client though today for my revdep tests. At least I think it's an issue

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2017-06-25 23:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (572 votes). Check out past polls.