Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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 taking refuge in the Monastery: (5)
As of 2018-03-18 15:55 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (230 votes). Check out past polls.