Perl in a Nutshell

Perl in a NutshellSearch this book
Previous: Reference: blessChapter 5
Function Reference
Next: Reference: chdir
 

caller

caller [n]

Returns information about the stack of current subroutine calls. Without an argument, it returns the package name in a scalar context, and in a list context, it returns the package name, filename, and line number that the currently executing subroutine was called from:

($package, $filename, $line) = caller;
With an argument it evaluates n as the number of stack frames to go back before the current one. It also reports some additional information that the debugger uses to print a stack trace:
$i = 0;
while (($pack, $file, $line, $subname, $hasargs, 
        $wantarray, $evaltext, $is_require) = caller($i++)) {
    ...
}
Furthermore, when called from within the DB package, caller returns more detailed information: it sets the list variable @DB::args to be the argument passed in the given stack frame.


Previous: Reference: blessPerl in a NutshellNext: Reference: chdir
Reference: blessBook IndexReference: chdir

Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.