parent(3pm)
π parent(3pm) β the Perl Programmers Reference Guide, but make it group-chat π
πΈ NAME πΈ
parentβ establish an ISA relationship with base classes at compile time. Periodt. π
β¨ SYNOPSIS β¨
package Baz;
use parent qw(Foo Bar);
π¦ DESCRIPTION π¦
Okay so bestie, this module lets you do two iconic things at once: load one or more modules, and set up inheritance from those modules at the same time. Mostly similar in effect to this:
package Baz;
BEGIN {
require Foo;
require Bar;
push @ISA, qw(Foo Bar);
}
By default, every base class needs to live in a file of its own. But if you want to have a subclass and its parent class in the same file, you can tell parent not to load any modules by using the -norequire switch:
package Foo;
sub exclaim { "I CAN HAS PERL" }
package DoesNotLoadFooBar;
use parent -norequire, 'Foo', 'Bar';
# will not go looking for Foo.pm or Bar.pm
This is equivalent to the following code:
package Foo;
sub exclaim { "I CAN HAS PERL" }
package DoesNotLoadFooBar;
push @DoesNotLoadFooBar::ISA, 'Foo', 'Bar';
This is also helpful for the case where a package lives within a differently named file:
package MyHash;
use Tie::Hash;
use parent -norequire, 'Tie::StdHash';
This is equivalent to the following code:
package MyHash;
require Tie::Hash;
push @ISA, 'Tie::StdHash';
If you want to load a subclass from a file that require would not consider an eligible filename β that is, it does not end in either .pm or .pmc β use the following code:
package MySecondPlugin;
require './plugins/custom.plugin'; # contains Plugin::Custom
use parent -norequire, 'Plugin::Custom';
π HISTORY π
This module was forked from base to remove the cruft that had accumulated in it. Spring cleaning era, honestly. π§Ήβ¨
π CAVEATS π
The CAVEATS section is literally empty in this one β nothing listed here, bestie. ππ«Ά
π SEE ALSO π
baseparent::versionedβ a fork ofparentthat provides version checking in parent class modules.
π«Ά AUTHORS AND CONTRIBUTORS π«Ά
RafaΓ«l Garcia-Suarez, Bart Lateur, Max Maischein, Anno Siegel, Michael Schwern. Absolute legends, all of them. π
π MAINTAINER π
Max Maischein β corion@cpan.org
Copyright (c) 2007-2017 Max Maischein <corion@cpan.org> Based on the idea of base.pm, which was introduced with Perl 5.004_04.
π LICENSE π
This module is released under the same terms as Perl itself. Slay, legally speaking. β
perl v5.42.3Β·2026-11-03Β·parent(3pm)β thatβs the whole manual, bestie. Go forth and inherit responsibly. πβ¨π¦
π¦ where this page comes from
- alpine 3.24: perl-doc 5.42.3-r0 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms