parent(3perl)
πΈ parent β the manual, but make it cute πΈ
okay bestie, so this is the parent(3perl) page π it's Perl, it's tiny, and it's about making your packages inherit from other packages at compile time. slay.
β¨ NAME β¨
parent β establish an ISA relationship with base classes at compile time π no cap, that's literally the whole job.
β¨ SYNOPSIS β¨
package Baz;
use parent qw(Foo Bar);
see how short that is?? iconic. two lines and you're a whole subclass π
β¨ DESCRIPTION β¨
okay so the deal is: this lets you load one or more modules and set up inheritance from those modules at the very same time. two birds, one use statement π¦ mostly the same effect as doing this by hand:
package Baz;
BEGIN {
require Foo;
require Bar;
push @ISA, qw(Foo Bar);
}
which, bestie, is a lot of typing for something you're gonna do like 400 times π
by default, every base class needs to live in a file of its own. that's the vibe. but if you want a subclass and its parent class chillin' in the same file (fr fr, same file), you tell parent not to load any modules by using the -norequire switch π like:
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
that is equivalent to the following code:
package Foo;
sub exclaim { "I CAN HAS PERL" }
package DoesNotLoadFooBar;
push @DoesNotLoadFooBar::ISA, 'Foo', 'Bar';
also it's so helpful for the case where a package lives inside a differently named file π like:
package MyHash;
use Tie::Hash;
use parent -norequire, 'Tie::StdHash';
which is equivalent to the following code:
package MyHash;
require Tie::Hash;
push @ISA, 'Tie::StdHash';
and last one, if you wanna load a subclass from a file that require would not consider an eligible filename (that means: it doesn't end in either .pm or .pmc, bestie, that's the rule), use this:
package MySecondPlugin;
require './plugins/custom.plugin'; # contains Plugin::Custom
use parent -norequire, 'Plugin::Custom';
okay now the random-ass file can be a parent. we love to see it π
β¨ HISTORY β¨
this module was forked from base to remove the cruft that had accumulated in it π§Ήβ¨ (yes, the original literally says "cruft". we respect the honesty.) lowkey iconic spring cleaning energy.
β¨ CAVEATS β¨
π bestie. this section is empty. as in, the original manpage puts a CAVEATS heading and then... nothing. no warnings, no notes, no drama. just vibes and silence. so we're keeping it empty too, because the one rule is keep every detail, and "there are no details here" is the detail π«Ά
β¨ SEE ALSO β¨
baseβ the OG it got forked from πΈparent::versionedβ a fork ofparentthat provides version checking in parent class modules π₯ (yes, that's genuinely what it does, that's not me editorialising)
β¨ AUTHORS AND CONTRIBUTORS β¨
the whole superstar lineup ππ :
- RafaΓ«l Garcia-Suarez
- Bart Lateur
- Max Maischein
- Anno Siegel
- Michael Schwern
β¨ 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. shoutout to the ancestors π«‘
β¨ LICENSE β¨
this module is released under the same terms as Perl itself β¨ free as in, go wild, bestie π¦
and that's the whole thing! this page (the parent bit of the Perl Programmers Reference Guide, manual section 3perl) was brought to you by perl v5.44.0, dated 2026-10-17 β go set up some inheritance and be the main character of your own @ISA ππ
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms