Chapter 15. Object-Oriented Programming

An object is a referent that knows which class it belongs to.

A class is a package that provides methods. If a package fails to provide a method, the base classes as listed in @ISA are searched, depth first.

A method is a subroutine that expects an invocant (an object reference or, for static methods, a package name) as the first argument.

bless ref [ , classname ]

Turns the referent ref into an object in classname (default is the current package). Returns the reference.

invocant-> method [ ( parameters ) ]

Calls the named method.

method invocant [ parameters ]

Provides an alternative way of calling a method, using the sometimes ambiguous indirect object syntax.

See also ref, and the next section.

perlobj, perlboot, perltoot, perltooc.

Get Perl Pocket Reference, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.