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

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

by Ovid (Cardinal)
on Feb 02, 2009 at 17:31 UTC ( #740753=note: print w/replies, xml ) Need Help??


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

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.

  • Comment on Re^2: Getting file and line number where a subroutine is declared

Replies are listed 'Best First'.
Re^3: Getting file and line number where a subroutine is declared
by ikegami (Pope) on Feb 02, 2009 at 17:47 UTC

    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://740753]
help
Chatterbox?
[Corion]: Meh. My bank removed (part of) their CSV download facilities. Now I will either have to implement a full scraper or automate the download using the HBCI interface instead (or just get a new account elsewhere...)
[Corion]: On the upside, I spend a lot of time thinking this weekend about how to actually implement rate limiting for futures, and if things work out, maybe even loading a configuration from an external file makes sense
[Corion]: I've also found some interesting invariants that I have to think/write about more. A simple rate limiter will never change the order of the input, while a limiter that allows for parallel execution will change the order. But my API currently allows for bo
[Corion]: ... for both, and I'm not sure if I want to add the cruft from the parallel API (a token that you need to hold on to while you hold the lock) to the rate limiting API too, to allow seamless up/downgrades, or not.
[Corion]: Also, rate limiting will look great with await: my $token = await $limiter-> limit($hostname); instead of my $f = $limiter->limit( $hostname )->then(sub { my( $token)=@_; ... });

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2017-10-23 08:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (277 votes). Check out past polls.

    Notices?