Perl 5 version 8.0 documentation



base - Establish IS-A relationship with base class at compile time


  1. package Baz;
  2. use base qw(Foo Bar);


Roughly similar in effect to

  1. BEGIN {
  2. require Foo;
  3. require Bar;
  4. push @ISA, qw(Foo Bar);
  5. }

Will also initialize the %FIELDS hash if one of the base classes has it. Multiple inheritance of %FIELDS is not supported. The 'base' pragma will croak if multiple base classes have a %FIELDS hash. See fields for a description of this feature.

When strict 'vars' is in scope base also let you assign to @ISA without having to declare @ISA with the 'vars' pragma first.

If any of the base classes are not loaded yet, base silently requires them. Whether to require a base class package is determined by the absence of a global $VERSION in the base package. If $VERSION is not detected even after loading it, <base> will define $VERSION in the base package, setting it to the string -1, set by .


This module was introduced with Perl 5.004_04.