This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Using Getopts::* with strict vars
[perl5.git] / lib / base.pm
1 =head1 NAME
2
3 base - 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
13 Roughly similar in effect to
14
15     BEGIN {
16         require Foo;
17         require Bar;
18         push @ISA, qw(Foo Bar);
19     }
20
21 This module was introduced with Perl 5.004_04.
22
23 =head1 BUGS
24
25 Needs proper documentation!
26
27 =cut
28
29 package base;
30
31 sub import {
32     my $class = shift;
33
34     foreach my $base (@_) {
35         unless (defined %{"$base\::"}) {
36             eval "require $base";
37             unless (defined %{"$base\::"}) {
38                 require Carp;
39                 Carp::croak("Base class package \"$base\" is empty.\n",
40                             "\t(Perhaps you need to 'use' the module ",
41                             "which defines that package first.)");
42             }
43         }
44     }
45     
46     push @{caller(0) . '::ISA'}, @_;
47 }
48
49 1;