background preloader

Higher-Order Perl

Higher-Order Perl

PerlMonks TJP September/99 Introduction Damian Conway is the author of the newly released Object Oriented Perl, the first of a new series of Perl books from Manning. Object-oriented programming in Perl is easy. Forget the heavy theory and the sesquipedalian jargon: classes in Perl are just regular packages, objects are just variables, methods are just subroutines. The syntax and semantics are a little different from regular Perl, but the basic building blocks are completely familiar. The one problem most newcomers to object-oriented Perl seem to stumble over is the notion of references and referents, and how the two combine to create objects in Perl. Let's start with a short detour down a dark alley... References and referents Sometimes it's important to be able to access a variable indirectly— to be able to use it without specifying its name. To handle such cases, Perl provides a special scalar datatype called a reference. Making a reference Figure 1 shows the relationships produced by those assignments. package Bug;

Related: