in reply to How to programmatically determine package where a sub was called

G'day einhverfr,

"So how can I detect the namespace of the subclass, at runtime, which calls this function?"

It sounds like caller will do what you want. There's three ways to use this function, each returns the caller's package name as the first argument:

$package = caller; ($package, $filename, $line) = caller; ($package, $filename, $line, $subroutine, $hasargs, $wantarray, $evaltext, $is_require, $hints, $bitmask, $hinthash) = caller($i);

See the doco for full details.

-- Ken

  • Comment on Re: How to programmatically determine package where a sub was called
  • Download Code