February 2012
Intermediate to advanced
1184 pages
37h 17m
English
use parent qw(Mother Father);
The parent pragma supersedes the base pragma. It loads modules and sets up inheritance
relationships without the %FIELDS hash
magic, and it provides a way to set up inheritance without loading
files.
The following example is equivalent to loading both parent modules
and adding them to @INC without
declaring @INC explicitly:
BEGIN {
require Mother;
require Father;
push @ISA, qw(Mother Father);
}This assumes each parent module lives
in its own file. If the parent classes do not live in separate files, perhaps because you’ve defined
them in the same file or already loaded them from a file as part of another class, you
can use the –norequire option
to merely set up the inheritance relationship:
use parent qw(–norequire Mother Father);
This is equivalent to adding those classes to @ISA:
BEGIN {
push @ISA, qw(Mother Father);
}Read now
Unlock full access