in reply to Getting file and line number where a subroutine is declared
It works better if it's rearranged.
use B; $\="\n"; package Foo; # line 23 'bin/some_file.pl' sub some_sub { warn "Got to here"; } # line 99 'bin/some_code.pl' print "some_sub: ",B::svref_2object(\&Foo::some_sub)->GV->LINE; { no strict 'refs'; print "some_other_sub: ",B::svref_2object(\*{'Foo::some_other_sub' +})->LINE; } Foo::some_sub(); __END__ some_sub: 25 some_other_sub: 102 Got to here at 'bin/some_file.pl' line 24.
This code is a little over my head to be honest, but my guess is that your references to Foo::some_sub in the no strict 'refs' block are creating the darned thing right there on the spot. Perhaps another monk can explain this behavior.
I don't know if this is helpful or not, but I found it interesting.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Getting file and line number where a subroutine is declared
by ikegami (Patriarch) on Feb 02, 2009 at 16:54 UTC | |
by kyle (Abbot) on Feb 02, 2009 at 19:19 UTC | |
by ikegami (Patriarch) on Feb 02, 2009 at 19:32 UTC |
In Section
Seekers of Perl Wisdom