Perl caller Function
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.
Following is the simple syntax for this function:
caller EXPR caller
This function returns undef on failure, basic information when called with no arguments and extended information when called with an argument.
Following is the example code showing its basic usage:
When above code is executed, it produced following result: