Perl Cheat Sheet Page 8

ADVERTISEMENT

caller
[
EXPR
]
Returns an array ( $ package, $ file, $ line,...) for a specific subroutine call.
‘ caller ’ returns this info for the current subroutine, ‘ caller(1) ’ for
the caller of this subroutine etc.. Returns false if no caller.
do SUBROUTINE LIST
Deprecated form of &
SUBROUTINE
.
goto
&
SUBROUTINE
Substitutes a call to
for the current subroutine.
SUBROUTINE
import MODULE
[
VERSION
] [
LIST
]
Imports the named items from
MODULE
. Checks the module for the
required
VERSION
.
[
]
no MODULE
LIST
Cancels imported semantics. See
.
use
package NAME
Designates the remainder of the current block as a package.
prototype NAME
Returns the prototype for this function.
y
require EXPR
If
is numeric, requires Perl to be at least that version. Otherwise
EXPR
must be the name of a file that is included from the Perl library. Does
EXPR
not include more than once, and yields a fatal error if the file does not
evaluate to a true value.
If
EXPR
is a bare word, assumes extension ‘ .pm ’ for the name of the file.
This form of loading of modules does not risk altering your namespace.
return EXPR
Returns from a subroutine with the value specified.
[ (
) ] {
; . . . }
sub NAME
PROTO
EXPR
Designates
as a subroutine. Parameters are passed by reference as
NAME
array @_ . Returns the value of the last expression evaluated.
can be used to define the required parameters.
PROTO
Without a
it is a forward declaration, without the
it is an
BLOCK
NAME
anonymous subroutine. Functions that have an empty prototype and do
nothing but return a fixed value are inlined.
[
sub
] BEGIN {
EXPR
; . . . }
Defines a setup
BLOCK
to be called before execution.
[
] END {
; . . . }
sub
EXPR
Defines a cleanup
to be called upon termination.
BLOCK
tie VAR, CLASSNAME,
[
LIST
]
Ties a variable to a package class that will handle it. Can be used to bind a
dbm or ndbm file to a hash.
tied VAR
Returns a reference to the object underlying
VAR
, or the undefined value if
VAR
is not tied to a package class.
untie VAR
Breaks the binding between the variable and the package class.
use VERSION
Requires perl version.
[
] [
]
use MODULE
VERSION
LIST
Imports semantics from the named module into the current package.
8

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education