Debian Codegraph @

upstream/opensuse-tumbleweed/man3/parent.3pm

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (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 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "parent 3pm"
61 .TH parent 3pm 2026-03-09 "perl v5.42.1" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 parent \- Establish an ISA relationship with base classes at compile time
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 .Vb 2
71 \& package Baz;
72 \& use parent qw(Foo Bar);
73 .Ve
74 .SH DESCRIPTION
75 .IX Header "DESCRIPTION"
76 Allows you to both load one or more modules, while setting up inheritance from
77 those modules at the same time. Mostly similar in effect to
78 .PP
79 .Vb 6
80 \& package Baz;
81 \& BEGIN {
82 \& require Foo;
83 \& require Bar;
84 \& push @ISA, qw(Foo Bar);
85 \& }
86 .Ve
87 .PP
88 By default, every base class needs to live in a file of its own.
89 If you want to have a subclass and its parent class in the same file, you
90 can tell \f(CW\*(C`parent\*(C'\fR not to load any modules by using the \f(CW\*(C`\-norequire\*(C'\fR switch:
91 .PP
92 .Vb 2
93 \& package Foo;
94 \& sub exclaim { "I CAN HAS PERL" }
95 \&
96 \& package DoesNotLoadFooBar;
97 \& use parent \-norequire, \*(AqFoo\*(Aq, \*(AqBar\*(Aq;
98 \& # will not go looking for Foo.pm or Bar.pm
99 .Ve
100 .PP
101 This is equivalent to the following code:
102 .PP
103 .Vb 2
104 \& package Foo;
105 \& sub exclaim { "I CAN HAS PERL" }
106 \&
107 \& package DoesNotLoadFooBar;
108 \& push @DoesNotLoadFooBar::ISA, \*(AqFoo\*(Aq, \*(AqBar\*(Aq;
109 .Ve
110 .PP
111 This is also helpful for the case where a package lives within
112 a differently named file:
113 .PP
114 .Vb 3
115 \& package MyHash;
116 \& use Tie::Hash;
117 \& use parent \-norequire, \*(AqTie::StdHash\*(Aq;
118 .Ve
119 .PP
120 This is equivalent to the following code:
121 .PP
122 .Vb 3
123 \& package MyHash;
124 \& require Tie::Hash;
125 \& push @ISA, \*(AqTie::StdHash\*(Aq;
126 .Ve
127 .PP
128 If you want to load a subclass from a file that \f(CW\*(C`require\*(C'\fR would
129 not consider an eligible filename (that is, it does not end in
130 either \f(CW\*(C`.pm\*(C'\fR or \f(CW\*(C`.pmc\*(C'\fR), use the following code:
131 .PP
132 .Vb 3
133 \& package MySecondPlugin;
134 \& require \*(Aq./plugins/custom.plugin\*(Aq; # contains Plugin::Custom
135 \& use parent \-norequire, \*(AqPlugin::Custom\*(Aq;
136 .Ve
137 .SH HISTORY
138 .IX Header "HISTORY"
139 This module was forked from base to remove the cruft
140 that had accumulated in it.
141 .SH CAVEATS
142 .IX Header "CAVEATS"
143 .SH "SEE ALSO"
144 .IX Header "SEE ALSO"
145 .IP base 4
146 .IX Item "base"
147 .PD 0
148 .IP parent::versioned 4
149 .IX Item "parent::versioned"
150 .PD
151 A fork of parent that provides version checking in parent class modules.
152 .SH "AUTHORS AND CONTRIBUTORS"
153 .IX Header "AUTHORS AND CONTRIBUTORS"
154 Rafaël Garcia\-Suarez, Bart Lateur, Max Maischein, Anno Siegel, Michael Schwern
155 .SH MAINTAINER
156 .IX Header "MAINTAINER"
157 Max Maischein \f(CW\*(C` [email protected] \*(C'\fR
158 .PP
159 Copyright (c) 2007\-2017 Max Maischein \f(CW\*(C`<[email protected]>\*(C'\fR
160 Based on the idea of \f(CW\*(C`base.pm\*(C'\fR, which was introduced with Perl 5.004_04.
161 .SH LICENSE
162 .IX Header "LICENSE"
163 This module is released under the same terms as Perl itself.