in reply to Re: Identify the package a subroutine is being called from
in thread Identify the package a subroutine is being called from

You can get more information by calling caller in list context

Actually (caller)[0] does call it in list context. The number of arguments to caller matters, though:

$ perl -wle 'sub foo { my @l = caller(); return scalar @l }; print foo +()' 3 $ perl -wle 'sub foo { my @l = caller(0); return scalar @l }; print fo +o()' 10

Replies are listed 'Best First'.
Re^3: Identify the package a subroutine is being called from
by pc88mxer (Vicar) on Jun 06, 2008 at 17:50 UTC
    You're right. How may we invoke caller? Let us count the ways:
    $package = caller; @info = caller; # -> ($package, $file, $line) $package = caller($i); @extra_info = caller($i); # -> ($pack, $file, $line, $sub, $hasargs, ...)