September 2002
Intermediate to advanced
496 pages
10h
English
A class usually provides a method for creating an object as well as methods for defining the behavior of an object. Although you may name the creation method whatever you wish in most Perl dialects, in .NET it must be named new in honor of both C++ and Java, where it is likewise mandatory.
The data contained in an object is composed of many pieces. A Student object, for example, might contain a NAME, a MAJOR, and a set of COURSES. One way to model this in Perl is to create an anonymous hash and then retrieve items from it. See the folder Object.
% type object.pl # # object.pl # $student = { NAME => Mike, MAJOR => Math, COURSES => [Calc, Trig, DiffE ] }; print $student->{NAME},"\n"; # the name print $student->{MAJOR},"\n"; ...Read now
Unlock full access