Debian Codegraph @

upstream/debian-unstable/man3/parent.3perl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "parent 3perl"
58 .TH parent 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide"
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 parent \- Establish an ISA relationship with base classes at compile time
65 .SH SYNOPSIS
66 .IX Header "SYNOPSIS"
67 .Vb 2
68 \& package Baz;
69 \& use parent qw(Foo Bar);
70 .Ve
71 .SH DESCRIPTION
72 .IX Header "DESCRIPTION"
73 Allows you to both load one or more modules, while setting up inheritance from
74 those modules at the same time. Mostly similar in effect to
75 .PP
76 .Vb 6
77 \& package Baz;
78 \& BEGIN {
79 \& require Foo;
80 \& require Bar;
81 \& push @ISA, qw(Foo Bar);
82 \& }
83 .Ve
84 .PP
85 By default, every base class needs to live in a file of its own.
86 If you want to have a subclass and its parent class in the same file, you
87 can tell \f(CW\*(C`parent\*(C'\fR not to load any modules by using the \f(CW\*(C`\-norequire\*(C'\fR switch:
88 .PP
89 .Vb 2
90 \& package Foo;
91 \& sub exclaim { "I CAN HAS PERL" }
92 \&
93 \& package DoesNotLoadFooBar;
94 \& use parent \-norequire, \*(AqFoo\*(Aq, \*(AqBar\*(Aq;
95 \& # will not go looking for Foo.pm or Bar.pm
96 .Ve
97 .PP
98 This is equivalent to the following code:
99 .PP
100 .Vb 2
101 \& package Foo;
102 \& sub exclaim { "I CAN HAS PERL" }
103 \&
104 \& package DoesNotLoadFooBar;
105 \& push @DoesNotLoadFooBar::ISA, \*(AqFoo\*(Aq, \*(AqBar\*(Aq;
106 .Ve
107 .PP
108 This is also helpful for the case where a package lives within
109 a differently named file:
110 .PP
111 .Vb 3
112 \& package MyHash;
113 \& use Tie::Hash;
114 \& use parent \-norequire, \*(AqTie::StdHash\*(Aq;
115 .Ve
116 .PP
117 This is equivalent to the following code:
118 .PP
119 .Vb 3
120 \& package MyHash;
121 \& require Tie::Hash;
122 \& push @ISA, \*(AqTie::StdHash\*(Aq;
123 .Ve
124 .PP
125 If you want to load a subclass from a file that \f(CW\*(C`require\*(C'\fR would
126 not consider an eligible filename (that is, it does not end in
127 either \f(CW\*(C`.pm\*(C'\fR or \f(CW\*(C`.pmc\*(C'\fR), use the following code:
128 .PP
129 .Vb 3
130 \& package MySecondPlugin;
131 \& require \*(Aq./plugins/custom.plugin\*(Aq; # contains Plugin::Custom
132 \& use parent \-norequire, \*(AqPlugin::Custom\*(Aq;
133 .Ve
134 .SH HISTORY
135 .IX Header "HISTORY"
136 This module was forked from base to remove the cruft
137 that had accumulated in it.
138 .SH CAVEATS
139 .IX Header "CAVEATS"
140 .SH "SEE ALSO"
141 .IX Header "SEE ALSO"
142 .IP base 4
143 .IX Item "base"
144 .PD 0
145 .IP parent::versioned 4
146 .IX Item "parent::versioned"
147 .PD
148 A fork of parent that provides version checking in parent class modules.
149 .SH "AUTHORS AND CONTRIBUTORS"
150 .IX Header "AUTHORS AND CONTRIBUTORS"
151 Rafaël Garcia-Suarez, Bart Lateur, Max Maischein, Anno Siegel, Michael Schwern
152 .SH MAINTAINER
153 .IX Header "MAINTAINER"
154 Max Maischein \f(CW\*(C` [email protected] \*(C'\fR
155 .PP
156 Copyright (c) 2007\-2017 Max Maischein \f(CW\*(C`<[email protected]>\*(C'\fR
157 Based on the idea of \f(CW\*(C`base.pm\*(C'\fR, which was introduced with Perl 5.004_04.
158 .SH LICENSE
159 .IX Header "LICENSE"
160 This module is released under the same terms as Perl itself.