Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Clear questions and runnable code
get the best and fastest answer

Comment on


\&Foo::some_sub autovivifies a sub stub at run-time (just like sub Foo::some_sub; would at compile-time).

So it will work fine as long as we don't make any reference to the sub in any compiled code that comes before the definition.

use B; $\="\n"; # line 99 'bin/' { no strict 'refs'; print B::svref_2object(eval q(\\*{'Foo::some_sub'}))->LINE; print B::svref_2object(eval q(\\&Foo::some_sub))->GV->LINE; } eval q{Foo::some_sub()}; package Foo; # line 23 'bin/' sub some_sub { warn "Got to here"; } __END__ 25 25 Got to here at 'bin/' line 24.

Of course, string eval has a code smell, but so does no strict 'refs'.

In reply to Re^3: 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

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (5)
    As of 2014-03-15 19:49 GMT
    Find Nodes?
      Voting Booth?

      Have you used a cryptocurrency?

      Results (321 votes), past polls