Reputation: 968
our @ISA = "Critter";
In which condition will I use @ISA
?
and why our @ISA
?.
Upvotes: 16
Views: 23381
Reputation: 81
@ISA is stand for ‘is a’, that means the array contains parents' package
Upvotes: 8
Reputation: 37136
To extend Mat's comment, stuff like this is extensively documented in the perldocs
.
Regarding @ISA
, here's what it says:
A Class is Simply a Package
...
Each package contains a special array called
@ISA
. The@ISA
array contains a list of that class's parent classes, if any. This array is examined when Perl does method resolution, which we will cover later.It is possible to manually set
@ISA
, and you may see this in older Perl code. Much older code also uses thebase
pragma. For new code, we recommend that you use theparent
pragma to declare your parents. This pragma will take care of setting@ISA
. It will also load the parent classes and make sure that the package doesn't inherit from itself.However the parent classes are set, the package's
@ISA
variable will contain a list of those parents. This is simply a list of scalars, each of which is a string that corresponds to a package name.
our
and @ISA
go hand in hand because @ISA
is expected to be a package variable.
Upvotes: 33