in reply to What package is foo() from?

Assuming you're using Exporter or something like that, then the fact is that foo is in the current namespace, the one it was imported into. If you want to know where it came from, you'd probably have to dink with the import function to record the import action somehow.

Another possibility (not necessarily recommended) is to add a "secret" protocol to the foo function whereby it returns its native package e.g. when passed a certain argument:

sub foo { $_[-1] eq '__WHENCE__' and return __PACKAGE__; . . . . }

A word spoken in Mind will reach its own level, in the objective world, by its own weight

Replies are listed 'Best First'.
Re^2: What package is foo() from?
by ikegami (Patriarch) on Jun 25, 2007 at 18:39 UTC

    caller knows the package name (show below) at run-time. Is there a way (B:: modules?) to extract it without calling the function?