in reply to Re^3: Can I retry "use" when module load fails?
in thread Can I retry "use" when module load fail ?

I noticed... but why? I have nothing to do with import. I already used Exporter to export my stuffs. so if use is identical to BEGIN {require...}, then that should be no problem sub import{} never existed in my module, and then I won't call it. What's the difference?

Replies are listed 'Best First'.
Re^5: Can I retry "use" when module load fails?
by NetWallah (Canon) on Apr 15, 2013 at 06:47 UTC
    Actually, you DO need to call the "import" method, in order to inject the "exported" methods and variables into your (main) namespace.

    Exporter documentation explains this :

    The Exporter module implements an import method which allows a module to export functions and variables to its users' namespaces.

                 "I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
            -- Dr. Cox, Scrubs

      So you mean even I don't have sub import in my module, but I still have to call ->import() for once after my require statement, so that Exporter can export?
        Yes. When you use Exporter in a module, it inherits a standard ->import() sub from Exporter, so your module does then have an import method even though you didn't define it yourself.

        All Exporter really does is make symbols available to be imported. Nothing actually happens until the useing module calls import to specify which of the available symbols it wants to import. (e.g., use POSIX 'ceil'; to import only the ceil symbol from POSIX.)