package Foo; sub foo { my $pkg = caller; if ($pkg ne __PACKAGE__ && defined &{$pkg."::foo"}) { # exported } else { # not } }