Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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.


Comment on Re: Advice on style

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://873678]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2014-07-26 04:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls