12.5. Tips for the C++ or Java Programmer

The object-oriented features of Perl may appear frighteningly sparse; in fact, they are the consequence of a careful design to avoid unnecessarily bloating the language. For instance, there is no this keyword for referring to the current object in a method; instead, it's passed as the first parameter, and you can pick your own name. Most people pick $self because the declaration my $self … has a nice ring to it (or because they are former Smalltalk programmers).

Run-time semantics alone determine whether a routine is an object method or a class method, so you can easily write one that swings both ways. (A common idiom makes an object method out of a constructor.)

There is nothing special about a constructor ...

Get Perl Debugged now with O’Reilly online learning.

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