Perl Cheat Sheet Page 10

ADVERTISEMENT

9. Object oriented programming
Perl rules of object oriented programming:
An object is simply a reference that happens to know which class it belongs to.
Objects are blessed, references are not.
A class is simply a package that happens to provide methods to deal with object
references.
If a package fails to provide a method, the base classes as listed in @ISA are
searched.
A method is simply a subroutine that expects an object reference (or a package
name, for static methods) as the first argument.
Methods can be applied with:
METHOD OBJREF PARAMETERS
or
OBJREF
METHOD PARAMETERS
->
10. Arithmetic functions
y
abs EXPR
Returns the absolute value of its operand.
atan2 Y, X


Returns the arctangent of
Y
/
X
in the range -
to
.
y
cos EXPR
Returns the cosine of
EXPR
(expressed in radians).
y
exp EXPR
Returns e to the power of
.
EXPR
y
int EXPR
Returns the integer portion of
.
EXPR
y
log EXPR
Returns natural logarithm (base e) of
.
EXPR
rand
[
EXPR
]
Returns a random fractional number between 0 and the value of
. If
EXPR
EXPR
is omitted, returns a value between 0 and 1.
y
sin EXPR
Returns the sine of
EXPR
(expressed in radians).
y
sqrt EXPR
Returns the square root of
EXPR
.
srand
[
EXPR
]
Sets the random number seed for the
rand
operator.
Returns the number of seconds since January 1, 1970. Suitable for feeding to
time
gmtime
and
localtime
.
10

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education