What's the difference between `use base` and @ISA in Perl?
oop, perl
Solution
The typical use of `@ISA` is
package Foo;
require Bar;
our @ISA = qw/Bar/;
The `base` and `parent` pragmas both load the requested class and modify `@ISA` to include it:
package Foo;
use base qw/Bar/;
If you want multiple inheritance, you can supply more than one module to `base` or `parent`:
package Foo;
use parent qw/Bar Baz/; #@ISA is now ("Bar", "Baz");
The `parent` pragma is new as of Perl 5.10.1, but it is installable from CPAN if you have an older version of Perl. It was created because the `base` pragma had become difficult to maintain due to "cruft that had accumulated in it." You should not see a difference in the basic use between the two.
Problem
I want to make a singleton class which extends DBI. should I be doing something like this: ``` use base 'Class::Singleton'; our @ISA = ('DBI'); ``` or this: ``` our @ISA = ('Class::Singleton', 'DBI'); ``` or something else? Not really sure what the difference between 'use base' and 'isa' is.