in reply to Detecting an imported function

Try checking the sub's compilation package. I'm using eval to cover just in case the value that was given to sub_package() isn't a code reference or whatever.

use B 'svref_2object'; sub sub_package { eval { svref_2object( shift )->STASH->NAME } }

Replies are listed 'Best First'.
Re^2: Detecting an imported function
by Ovid (Cardinal) on Nov 18, 2005 at 03:19 UTC

    So far this is looking like a great solution. It's eliminated the need for me to worry about other solutions. I may do more work with this in the future, but for now this is wonderful. Thanks!

    Cheers,
    Ovid

    New address of my CGI Course.

      By placing this at the end of my file, it runs after all use() and ->import has occurred. Any imported methods will be visible now. Because my caller called me with a use() call, this code is run during the BEGIN-time of my caller. This is what I imagined tye was suggesting.

      package Example; use vars qw( @Methods ); use Anything::You::Like; ... no strict 'refs'; @Methods = grep *{__PACKAGE__ . "::$_"}{CODE}, $keys %{__PACKAGE__ . " +::"}; 1;