[Za-pm] sub name in a special var?

James Keenan jkeen at verizon.net
Fri Jun 10 17:06:39 PDT 2005


On Jun 10, 2005, at 8:56 AM, Spike wrote:

> Hi All
> Is there a special var that holds, or a function that returns the name 
> of
> the current subroutine in the came way that $0 holds the script name or
> caller() returns the calling package?
>
>

Yes, it's called ... caller!

 From perldoc -f caller

        caller EXPR
        [snip]
                With EXPR, it returns some extra information that the 
debugger
                uses to print a stack trace.  The value of EXPR 
indicates how
                many call frames to go back before the current one.

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

So, is there some reason why element[3] in the above list won't work 
for you?

Jim Keenan





More information about the Za-pm mailing list