Perl Cheat Sheet Page 9

ADVERTISEMENT

Standard methods
The
UNIVERSAL
package contains the following methods that are inherited by all
other classes:
isa CLASS
Returns true if its object is blessed into a subclass of
.
CLASS
can METHOD
Returns a reference to the method if its object has it, undef otherwise.
VERSION
[
NEED
]
Returns the version of the class. Checks the version if
NEED
is supplied.
8. Pragmatic modules
Pragmatic modules affect the compilation of your program. Pragmatic modules can
be activated (imported) with
use
, and deactivated with
no
. These are locally
scoped.
autouse MODULE
SUBS
=>
Defers
until one of the subs is called.
require
blib
[
DIR
]
Used for testing of uninstalled packages.
constant NAME
VALUE
=
Defines
NAME
to have a constant (compile-time) value.
diagnostics
Force verbose warning diagnostics.
integer
Compute arithmetic in integer instead of double precision.
less
Request less of something from the compiler.
lib
Manipulate @INC at compile time.
Enable POSIX locales.
locale
Restrict unsafe operations when compiling.
ops
overload
Package for overloading Perl operators.
Example: use overload "+" => \&my_add;
sigtrap
Enable simple signal handling.
Example: use sigtrap qw(SEGV TRAP);
Restrict unsafe constructs.
strict
use strict "refs" restricts the use of symbolic references.
use strict "vars" requires all variables to be either local or fully
qualified.
use strict "subs" restricts the use of bareword identifiers that are
not subroutines.
Predeclare subroutine names, allowing you to use them without
subs
parentheses even before they are declared.
Example: use subs qw(ding dong);
vars
Predeclare variable names, allowing you to use them under “use strict”.
Example: use vars qw($foo @bar);
vmsish
Emulate some VMS behaviour.
9

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education