I have a module say Foo.pm
package Foo;
sub new {
}
sub SomeMethod {
}
1;
Then a subclass,Foo::Bar Foo/Bar.pm
package Foo::Bar;
use base Foo;
use Foo;
sub SomeMethod {
}
1;
Now do we need to use
use base Foo;
use Foo;
or just
use base Foo;
will do both.
Also if we need to use use Foo;
What different does it do?
use base Module;will always load the package if needed, but it won’t import from it. It’s similar touse Module;, on the other hand, will import the module’s default exports*. It’s similar toSo the
use Foo;followinguse base 'Foo';isn’t required unless you want to import from the module.* — Technically, it merely calls
importwith no arguments if the module defines such a method. What I described is the normal behaviour ofimportmethods.