package parent; use strict; use vars qw($VERSION); $VERSION = '0.225'; sub import { my $class = shift; my $inheritor = caller(0); if ( @_ and $_[0] eq '-norequire' ) { shift @_; } else { for ( my @filename = @_ ) { if ( $_ eq $inheritor ) { warn "Class '$inheritor' tried to inherit from itself\n"; }; s{::|'}{/}g; require "$_.pm"; # dies if the file is not found } } { no strict 'refs'; push @{"$inheritor\::ISA"}, @_; }; }; "All your base are belong to us" __END__ =encoding utf8 =head1 NAME parent - Establish an ISA relationship with base classes at compile time =head1 SYNOPSIS package Baz; use parent qw(Foo Bar); =head1 DESCRIPTION Allows you to both load one or more modules, while setting up inheritance from those modules at the same time. Mostly similar in effect to package Baz; BEGIN { require Foo; require Bar; push @ISA, qw(Foo Bar); } By default, every base class needs to live in a file of its own. If you want to have a subclass and its parent class in the same file, you can tell C<parent> not to load any modules by using the C<-norequire> switch: package Foo; sub exclaim { "I CAN HAS PERL" } package DoesNotLoadFooBar; use parent -norequire, 'Foo', 'Bar'; # will not go looking for Foo.pm or Bar.pm This is equivalent to the following code: package Foo; sub exclaim { "I CAN HAS PERL" } package DoesNotLoadFooBar; push @DoesNotLoadFooBar::ISA, 'Foo', 'Bar'; This is also helpful for the case where a package lives within a differently named file: package MyHash; use Tie::Hash; use parent -norequire, 'Tie::StdHash'; This is equivalent to the following code: package MyHash; require Tie::Hash; push @ISA, 'Tie::StdHash'; If you want to load a subclass from a file that C<require> would not consider an eligible filename (that is, it does not end in either C<.pm> or C<.pmc>), use the following code: package MySecondPlugin; require './plugins/custom.plugin'; # contains Plugin::Custom use parent -norequire, 'Plugin::Custom'; =head1 DIAGNOSTICS =over 4 =item Class 'Foo' tried to inherit from itself Attempting to inherit from yourself generates a warning. package Foo; use parent 'Foo'; =back =head1 HISTORY This module was forked from L<base> to remove the cruft that had accumulated in it. =head1 CAVEATS =head1 SEE ALSO L<base> =head1 AUTHORS AND CONTRIBUTORS Rafaƫl Garcia-Suarez, Bart Lateur, Max Maischein, Anno Siegel, Michael Schwern =head1 MAINTAINER Max Maischein C< corion@cpan.org > Copyright (c) 2007-10 Max Maischein C<< <corion@cpan.org> >> Based on the idea of C<base.pm>, which was introduced with Perl 5.004_04. =head1 LICENSE This module is released under the same terms as Perl itself. =cut
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
App | Folder | 0755 |
|
|
Archive | Folder | 0755 |
|
|
Authen | Folder | 0755 |
|
|
B | Folder | 0755 |
|
|
Bundle | Folder | 0755 |
|
|
Business | Folder | 0755 |
|
|
CGI | Folder | 0755 |
|
|
CPAN | Folder | 0755 |
|
|
CPANPLUS | Folder | 0755 |
|
|
Carp | Folder | 0755 |
|
|
DBIx | Folder | 0755 |
|
|
Data | Folder | 0755 |
|
|
Date | Folder | 0755 |
|
|
Devel | Folder | 0755 |
|
|
Digest | Folder | 0755 |
|
|
Encode | Folder | 0755 |
|
|
Error | Folder | 0755 |
|
|
Exporter | Folder | 0755 |
|
|
ExtUtils | Folder | 0755 |
|
|
File | Folder | 0755 |
|
|
Getopt | Folder | 0755 |
|
|
Git | Folder | 0755 |
|
|
HTML | Folder | 0755 |
|
|
HTTP | Folder | 0755 |
|
|
IO | Folder | 0755 |
|
|
IPC | Folder | 0755 |
|
|
JSON | Folder | 0755 |
|
|
LWP | Folder | 0755 |
|
|
Locale | Folder | 0755 |
|
|
Log | Folder | 0755 |
|
|
Folder | 0755 |
|
||
Module | Folder | 0755 |
|
|
Mozilla | Folder | 0755 |
|
|
Net | Folder | 0755 |
|
|
POD2 | Folder | 0755 |
|
|
Params | Folder | 0755 |
|
|
Parse | Folder | 0755 |
|
|
Perl | Folder | 0755 |
|
|
Pod | Folder | 0755 |
|
|
RPC | Folder | 0755 |
|
|
TAP | Folder | 0755 |
|
|
Term | Folder | 0755 |
|
|
Test | Folder | 0755 |
|
|
Text | Folder | 0755 |
|
|
Thread | Folder | 0755 |
|
|
Time | Folder | 0755 |
|
|
Try | Folder | 0755 |
|
|
Types | Folder | 0755 |
|
|
Version | Folder | 0755 |
|
|
WWW | Folder | 0755 |
|
|
auto | Folder | 0755 |
|
|
autodie | Folder | 0755 |
|
|
common | Folder | 0755 |
|
|
inc | Folder | 0755 |
|
|
lib | Folder | 0755 |
|
|
local | Folder | 0755 |
|
|
CGI.pm | File | 255.24 KB | 0644 |
|
CPANPLUS.pm | File | 7.05 KB | 0644 |
|
Carp.pm | File | 19.93 KB | 0644 |
|
Digest.pm | File | 10.35 KB | 0644 |
|
Env.pm | File | 5.39 KB | 0644 |
|
Error.pm | File | 24.27 KB | 0644 |
|
Expect.pm | File | 53.44 KB | 0644 |
|
Expect.pod | File | 42.71 KB | 0644 |
|
Exporter.pm | File | 18.31 KB | 0644 |
|
Fatal.pm | File | 45.16 KB | 0644 |
|
Git.pm | File | 42.55 KB | 0444 |
|
JSON.pm | File | 67.04 KB | 0644 |
|
Readonly.pm | File | 21.94 KB | 0644 |
|
autodie.pm | File | 11.83 KB | 0644 |
|
constant.pm | File | 13.04 KB | 0644 |
|
newgetopt.pl | File | 2.15 KB | 0644 |
|
parent.pm | File | 2.83 KB | 0644 |
|
perldoc.pod | File | 8.25 KB | 0644 |
|