Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://873678]
help
Chatterbox?
[amitkumarj441]: Hey everyone
[amitkumarj441]: I need to ask a question, where can I post my problem?
[Discipulus]: everyone is me
[Discipulus]: Seekers of Perl Wisdom is the for asking question
[Discipulus]: be sure to use code tags for code and data
[Discipulus]: and to show some effort while asking
[Discipulus]: <code> code and data</code>
[Discipulus]: amitkumarj441 more atention you put asking, more attentio you got in answers
Discipulus 's hoping he needs a oneliner ;=)

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2017-04-26 20:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (488 votes). Check out past polls.