D.5. Statements

The following tables detail the various statements present in the Perl language.

D.5.1. Subroutines, Packages, and Modules

Function/StatementUse
&subroutine listExecutes subroutine. Note: The & may be omitted if the subroutine has been declared before being used.
bless ref [ , package ]Turns the object ref into an object in package. Returns ref.
caller [ expr ]Returns an array containing the context for a specific subroutine call ($package,$file,$line). Using expr specifies how many call frames to go back from the current frame. When expr is used, the routine returns extra information in the array ($package, $filename, $line, $subroutine, $hasargs, $wantarray, $evaltext, $is_require, $hints, $bitmask). Returns false if there is no caller. (If expr is used, this function returns additional debugging info.)
goto &subroutineSubstitutes a call to subroutine for the currently running subroutine.
import module [ [ version ] list]Imports the named subroutines from module into the current program.
no module [ list ]Cancels imported semantics.
package nameDesignates the remainder of the current block as a package.
require exprCan be used in multiple contexts: If expr is numeric, statement requires Perl to be at least the version in expr. If expr is nonnumeric, it indicates a name of a file to be included from the Perl library. (The .pm extension is assumed if none is given.)
return exprReturns from a subroutine with the value specified.
sub name { expr ; . . . }Designates name

Get Web Standards Programmer's Reference: HTML, CSS, JavaScript®, Perl, Python®, and PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.