O'Reilly logo

Computer Science & Perl Programming by Jon Orwant

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Using Object-Oriented Modules

Sean M. Burke

The first time most Perl programmers run into object-oriented programming is when they need to use a module with an object-oriented interface. This is often a mystifying experience, since talk of “methods” and “constructors” is unintelligible to programmers who thought that functions and variables were all there was to worry about.

Articles and books that explain object-oriented programming (OOP) do so from the perspective of the programmer. That’s understandable, and if you learn to write object-oriented code of your own, you’d find it easy to use object-oriented code that others write. But this approach is the long way around for people whose immediate goal is just to use existing object-oriented modules, but don’t yet want to know all the gory details of writing such modules for themselves.

This article is for those programmers—programmers who want to know about objects from the perspective of using object-oriented modules.

Modules and Their Functional Interfaces

Modules are the primary mechanism for bundling up Perl code for later use by yourself or others. As I’m sure you can’t help noticing from reading The Perl Journal, CPAN (the Comprehensive Perl Archive Network) is the repository for modules that others have written, for anything from composing music to downloading web pages. Many modules are bundled with every installation of Perl.

Text::Wrap is one module you may have used that has a fairly typical interface. It comes ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required