in reply to Reading and capturing the import list

The module's import() sub is called with the list specified when the module is used. So, something like this will do:

package Foo; sub import { my $class = shift; # It's called as a class method. @Foo::urls = @_; } 1;

Update: See PodMaster's comments below. He is entirely correct. I've edited the code above to reflect that. (And, thanks PodMaster, for catching my thinko.)

-sauoq
"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
Re: Re: Reading and capturing the import list
by PodMaster (Abbot) on Jul 03, 2003 at 05:54 UTC
    It is a method, so the 1st argument will be the package/class name ;)
    C:\>perldoc -f import
        import  There is no builtin "import" function. It is just an ordinary
                method (subroutine) defined (or inherited) by modules that wish
                to export names to another module. The "use" function calls the
                "import" method for the package used. See also "use", perlmod,
                and Exporter.
    
    jacques (or anyone wanting to learn about modules) should read `perldoc -f perlmod' and the documentation it references.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: Re: Reading and capturing the import list
by jacques (Priest) on Jul 03, 2003 at 04:27 UTC
    I don't have to worry about the package not finding a subroutine called "http://www.perlmonks.org"?

      No. It's a generic mechanism. It is only by convention that we use it to export sub names and global variables. It can be easily adapted to do what you are trying to do.

      -sauoq
      "My two cents aren't worth a dime.";