1base(3pm) Perl Programmers Reference Guide base(3pm)
2
3
4
6 base - Establish an ISA relationship with base classes at compile time
7
9 package Baz;
10 use base qw(Foo Bar);
11
13 Unless you are using the "fields" pragma, consider this module
14 discouraged in favor of the lighter-weight "parent".
15
16 Allows you to both load one or more modules, while setting up
17 inheritance from those modules at the same time. Roughly similar in
18 effect to
19
20 package Baz;
21 BEGIN {
22 require Foo;
23 require Bar;
24 push @ISA, qw(Foo Bar);
25 }
26
27 "base" employs some heuristics to determine if a module has already
28 been loaded, if it has it doesn't try again. If "base" tries to
29 "require" the module it will not die if it cannot find the module's
30 file, but will die on any other error. After all this, should your base
31 class be empty, containing no symbols, it will die. This is useful for
32 inheriting from classes in the same file as yourself, like so:
33
34 package Foo;
35 sub exclaim { "I can have such a thing?!" }
36
37 package Bar;
38 use base "Foo";
39
40 If $VERSION is not detected even after loading it, <base> will define
41 $VERSION in the base package, setting it to the string "-1, set by
42 base.pm".
43
44 "base" will also initialize the fields if one of the base classes has
45 it. Multiple inheritance of fields is NOT supported, if two or more
46 base classes each have inheritable fields the 'base' pragma will croak.
47 See fields, public and protected for a description of this feature.
48
49 The base class' "import" method is not called.
50
52 Base class package "%s" is empty.
53 base.pm was unable to require the base package, because it was not
54 found in your path.
55
56 Class 'Foo' tried to inherit from itself
57 Attempting to inherit from yourself generates a warning.
58
59 use Foo;
60 use base 'Foo';
61
63 This module was introduced with Perl 5.004_04.
64
66 Due to the limitations of the implementation, you must use base before
67 you declare any of your own fields.
68
70 fields
71
72
73
74perl v5.12.4 2011-06-07 base(3pm)