Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Advice on style

by JavaFan (Canon)
on Nov 25, 2010 at 16:24 UTC ( #873678=note: print w/replies, xml ) Need Help??

in reply to Advice on style

It doesn't matter. What happens is:
  1. Some other module or program uses your module.
  2. During its compilation, the perl compiler encounters "use Module1";
  3. This triggers your module to get compiled; while doing so, Module2 and Module3 will get compiled (if not already compiled). Module2->import and Module3->import will be called.
  4. Your module will run. First thing it does is to compile Exporter (if it hasn't been compiled already).
  5. Then Module1->import is called (assuming that other module or program uses "use Module1"). Which means Exporter::import is called.
  6. Exporter::import exports fn1 and fn2 to the calling module or program.
  7. Perl will resume compiling the calling module or program.
It doesn't matter where you place 'require Exporter'.

I've never understood why people use the idiom 'require Exporter'. I never do. 'use Exporter();' also compiles Exporter without calling import.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://873678]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2018-06-22 12:29 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (124 votes). Check out past polls.