in reply to How to tell if a sub has been exported?

It's not complete but would be suffice for many cases.
package Foo; sub foo { my $pkg = caller; if ($pkg ne __PACKAGE__ && defined &{$pkg."::foo"}) { # exported } else { # not } }
About another question, making variable init as a closure is well-known idiom (see Ima::DBI which makes DB connection as a clusure) and you are not wrong about it IMHO.

--
Tatsuhiko Miyagawa
miyagawa@cpan.org

Replies are listed 'Best First'.
Re: Re: How to tell if a sub has been exported?
by rrwo (Friar) on Oct 06, 2001 at 08:26 UTC

    How can I tell from another routine in the module (such as INIT) that the subroutine has been imported?

      Sorry for that this is not a direct answer, but you've wrote
      The real reason is that foo requires a bit of initialization, and I don't want to do this unless necessary.
      I think this is completely irrelevant to import/export. Making closure will be enough, and using Autoloader would be another option.

      --
      Tatsuhiko Miyagawa
      miyagawa@cpan.org