This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
tweaks to overloaded constants (change#1259)
[perl5.git] / lib / base.pm
CommitLineData
fb73857a 1=head1 NAME
2
3base - Establish IS-A relationship with base class at compile time
4
5=head1 SYNOPSIS
6
7 package Baz;
8
9 use base qw(Foo Bar);
10
11=head1 DESCRIPTION
12
13Roughly similar in effect to
14
15 BEGIN {
16 require Foo;
17 require Bar;
18 push @ISA, qw(Foo Bar);
19 }
20
21This module was introduced with Perl 5.004_04.
22
23=head1 BUGS
24
25Needs proper documentation!
26
27=cut
28
29package base;
30
31sub import {
32 my $class = shift;
33
34 foreach my $base (@_) {
35 unless (defined %{"$base\::"}) {
36 eval "require $base";
9b599b2a
GS
37 # Only ignore "Can't locate" errors from our eval require.
38 # Other fatal errors (syntax etc) must be reported.
39 die if $@ && $@ !~ /^Can't locate .*? at \(eval /;
fb73857a 40 unless (defined %{"$base\::"}) {
41 require Carp;
42 Carp::croak("Base class package \"$base\" is empty.\n",
43 "\t(Perhaps you need to 'use' the module ",
44 "which defines that package first.)");
45 }
46 }
47 }
48
49 push @{caller(0) . '::ISA'}, @_;
50}
51
521;