1parent(3)             User Contributed Perl Documentation            parent(3)
2
3
4

NAME

6       parent - Establish an ISA relationship with base classes at compile
7       time
8

SYNOPSIS

10           package Baz;
11           use parent qw(Foo Bar);
12

DESCRIPTION

14       Allows you to both load one or more modules, while setting up
15       inheritance from those modules at the same time.  Mostly similar in
16       effect to
17
18           package Baz;
19           BEGIN {
20               require Foo;
21               require Bar;
22               push @ISA, qw(Foo Bar);
23           }
24
25       By default, every base class needs to live in a file of its own.  If
26       you want to have a subclass and its parent class in the same file, you
27       can tell "parent" not to load any modules by using the "-norequire"
28       switch:
29
30         package Foo;
31         sub exclaim { "I CAN HAS PERL" }
32
33         package DoesNotLoadFooBar;
34         use parent -norequire, 'Foo', 'Bar';
35         # will not go looking for Foo.pm or Bar.pm
36
37       This is equivalent to the following code:
38
39         package Foo;
40         sub exclaim { "I CAN HAS PERL" }
41
42         package DoesNotLoadFooBar;
43         push @DoesNotLoadFooBar::ISA, 'Foo', 'Bar';
44
45       This is also helpful for the case where a package lives within a
46       differently named file:
47
48         package MyHash;
49         use Tie::Hash;
50         use parent -norequire, 'Tie::StdHash';
51
52       This is equivalent to the following code:
53
54         package MyHash;
55         require Tie::Hash;
56         push @ISA, 'Tie::StdHash';
57
58       If you want to load a subclass from a file that "require" would not
59       consider an eligible filename (that is, it does not end in either ".pm"
60       or ".pmc"), use the following code:
61
62         package MySecondPlugin;
63         require './plugins/custom.plugin'; # contains Plugin::Custom
64         use parent -norequire, 'Plugin::Custom';
65

HISTORY

67       This module was forked from base to remove the cruft that had
68       accumulated in it.
69

CAVEATS

SEE ALSO

72       base
73       parent::versioned
74           A fork of parent that provides version checking in parent class
75           modules.
76

AUTHORS AND CONTRIBUTORS

78       Rafaƫl Garcia-Suarez, Bart Lateur, Max Maischein, Anno Siegel, Michael
79       Schwern
80

MAINTAINER

82       Max Maischein " corion@cpan.org "
83
84       Copyright (c) 2007-2017 Max Maischein "<corion@cpan.org>" Based on the
85       idea of "base.pm", which was introduced with Perl 5.004_04.
86

LICENSE

88       This module is released under the same terms as Perl itself.
89
90
91
92perl v5.30.1                      2020-02-07                         parent(3)
Impressum