Home / Alt manpages / perltoot(1)

  • perltoot(1)
  • User command
  • linux

Find the Right Perl OO Documentation from perltoot

You will finish with a reliable reading path for object-oriented Perl: use perltoot as the signpost, start with perlootut when you are learning, and move to perlobj when you need the language-level details. On this machine the installed documentation belongs to Perl 5.38.2 and the perl-doc package. Allow about fifteen minutes for the first pass, or longer if you are also working through the examples.

This is a documentation workflow, not an installation guide. You need a shell and the perl-doc package. The commands below only read local manual pages and print their locations. They do not modify Perl, your module tree or any project files.

1. Confirm the Perl version and documentation package

Start by recording the version whose manuals you are about to read. Documentation can differ between Perl releases, so this small check prevents you from silently following a different installation.

$ perl --version

This is perl 5, version 38, subversion 2 (v5.38.2) built for x86_64-linux-gnu-thread-multi
$ dpkg-query -W -f='${Package} ${Version}\n' perl-doc
perl-doc 5.38.2-3.2ubuntu0.6

The exact build text can vary with architecture and vendor patches. The useful facts are the Perl release and the package providing the documentation. If dpkg-query reports that perl-doc is not installed, do not assume that an online page is an exact match for your interpreter. Ask your system administrator or use your normal package-management process to install the matching documentation package.

Checkpoint

Keep the reported Perl version visible while you read. It is the boundary for the examples and wording in this guide.

The installed perltoot page is intentionally short. Its job is to direct you to the two documents that replaced the older tutorial that used to occupy that name:

$ man perltoot
PERLTOOT(1)             Perl Programmers Reference Guide              PERLTOOT(1)

NAME
       perltoot - Links to information on object-oriented programming in Perl

DESCRIPTION
       For information on OO programming with Perl, please see perlootut and perlobj.

       (The above documents supersede the tutorial that was formerly here in perltoot.)

There is no class generator, project template or configuration file hidden behind this command. Treat perltoot as a map. If you expected a complete tutorial and find only a pointer, the command is behaving correctly.

For a compact check that the manual database can resolve all three names, run:

$ man -w perltoot perlootut perlobj
/usr/share/man/man1/perltoot.1.gz
/usr/share/man/man1/perlootut.1.gz
/usr/share/man/man1/perlobj.1.gz

Your paths may differ. The important result is one resolved path for each page. If one name is missing, repair the local documentation installation before diagnosing Perl code.

3. Read perlootut for the practical route

Use perlootut first when your goal is to understand or write object-oriented Perl. The page introduces the shared vocabulary of objects, classes, methods and attributes, then explains how Perl's built-in OO model relates to common CPAN object systems. It assumes that you already know basic Perl syntax, variables, operators and subroutine calls.

$ man perlootut
$ man perlintro

Read perlintro first if the tutorial's assumptions do not hold yet. The tutorial also points readers towards perlsyn, perlop and perlsub for language fundamentals. Do not skip that distinction: an unfamiliar OO example is often a Perl syntax problem rather than an OO problem.

The tutorial's opening material is useful for choosing an abstraction. Perl classes are packages used as classes, and objects are data structures associated with a class. Perl does not require a special class declaration or a special constructor keyword. That flexibility is part of the language, but it also means that different projects can use different object systems and conventions.

When the tutorial recommends a CPAN object system, treat that as a design choice to review against the project's existing dependencies. Do not add a module merely to make an isolated example run. First inspect the project's dependency policy and lock files, then test the selected module in a disposable branch or working copy.

4. Use perlobj when the mechanism matters

Switch to perlobj when you need to maintain older object code, understand method dispatch, or write an object system from scratch. It is a reference to Perl's OO features rather than the shortest route to a new application.

$ man perlobj
$ man perlreftut

The reference starts from three useful principles: an object is a data structure associated with a class, a class is a package that provides methods, and a method is a subroutine that receives an object or class name as its first argument. Perl's bless function creates that association. The common constructor name new is a convention, not a language keyword.

This matters when reading unfamiliar code. A package can be used as a class without a special declaration, and a constructor can have another name. The presence of a hash reference and a method named new is a convention worth recognising, not proof of a required Perl syntax.

For application code, prefer the object system already chosen by the project unless you have a documented reason to change it. Mixing hand-built blessed references with a framework's conventions increases the amount of code a maintainer must understand. When maintaining hand-built objects, read perlobj closely and treat the internal data structure as an implementation detail at the call sites.

5. Verify examples without changing your project

You can check that the interpreter is usable without installing a module or writing a file:

$ perl -e 'print "Perl OO documentation path is ready\n"'
Perl OO documentation path is ready

This only verifies that Perl can execute a one-line program. It does not validate a CPAN module, a project's class design or the behaviour of an example copied from a manual. For an actual example, copy it into a temporary file or a disposable checkout, then run the project's normal test command.

Keep code examples separate from a production module until you understand their assumptions. In particular, do not paste a constructor or a bless call into a live service as a quick fix. That changes runtime behaviour and can create an object whose invariants are not established. There is no generic undo for a code change: use version control to review and revert your own change, and preserve uncommitted work before experimenting.

6. Diagnose the usual wrong turn

If man perltoot says that no manual entry exists, check the search path and package state rather than inventing a replacement page:

$ man -w perltoot
$ dpkg-query -W -f='${Status} ${Package} ${Version}\n' perl-doc
install ok installed perl-doc 5.38.2-3.2ubuntu0.6

If the package is installed but man still cannot find the entry, inspect the configured manual paths with man --path and ask your administrator to repair the package's manual database. Running sudo mandb is not a first step and is not needed when the manual is already resolvable. Elevated privileges do not make a missing document authoritative.

If the page opens but its examples do not fit the project, return to perlootut to identify the concepts, then inspect the project's existing modules and tests. Documentation tells you what Perl can do; it does not choose your dependency policy, API boundary or deployment rollback plan.

Done means

  • You recorded the installed Perl release and the perl-doc package version.
  • perltoot resolved and you understood it as a pointer to perlootut and perlobj.
  • You chose perlootut for learning and practical design, or perlobj for low-level reference and maintenance.
  • You checked any copied example in a disposable context before changing a project.
  • No package, module tree, service or project file was changed by this workflow.