in reply to Confused by use base, I think.

Use base is intended to include code from another another package into your current one. The way I am reading your code, it looks like you are trying to base an object and hope that it inherits its methods, and that is not right. use base should be used like this,

package My::New::Module::Admin; use base 'My::New::Module::WWW';

All the code in My::New::Module::WWW is now available in your child package My::New::Module::Admin. Does that help?

Replies are listed 'Best First'.
Re^2: Confused by use base, I think.
by ikegami (Patriarch) on Jun 15, 2008 at 05:56 UTC

    You have it completely backwards.

    Use base is intended to include code from another another package into your current one

    Not at all. base is intended to load a module and setup an inheritance relationship in one step.

    In fact, since base doesn't even call the module's import function, it's intention are exactly the opposite of what you say they are.

      On a technical level, you are correct, but sometimes to wrap your head around an idea you present it in a way someone has to understand it. For someone who may not understand the difference you approach the idea in a way they can comprehend not the terminology they may or may not understand.

        It's one thing to gloss over details. It's quite another to say that base doesn't create an inheritance relationship ("it looks like you are trying to base an object and hope that it inherits its methods, and that is not right.") and that its purpose is to make the following work ("Use base is intended to include code from another another package into your current one.")

        >type WWW.pm package WWW; sub www_func { print("woot!\n"); } 1; >type Admin.pm package Admin; use base 'WWW'; www_func(); 1; >perl -e"use Admin" Undefined subroutine &Admin::www_func called at Admin.pm line 3. Compilation failed in require at -e line 1. BEGIN failed--compilation aborted at -e line 1.

        And the OP's problem didn't even have anything to do with inheritance.