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.
In reply to Re: Getting file and line number where a subroutine is declared
by kyle
in thread Getting file and line number where a subroutine is declared
by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |