Perl caller Function



Description

This function returns information about the current subroutines caller. In a scalar context, returns the caller's package name or the package name of the caller EXPR steps up.

In a list context, with no arguments specified, caller returns the package name, file name and line within the file for the caller of the current subroutine.

If EXPR is specified, caller returns extended information for the caller EXPR steps up. That is, when called with an argument of 1, it returns the information for the caller (parent) of the current subroutine, with 2 the caller of the caller (grandparent) of the current subroutine, and so on.

Syntax

Following is the simple syntax for this function −

caller EXPR

caller

Return Value

This function returns undef on failure, basic information when called with no arguments and extended information when called with an argument.

perl_function_references.htm
Advertisements