Try this for a demo. Save it into 3 files, as indicated:
Result:# Module Foo2, file Foo2.pm package Foo2; warn "module Foo2's run time"; BEGIN { warn "module Foo2's compile time"; } use Foo1; BEGIN { warn "module Foo2's compile time"; } sub import { warn "$_[0]\->import() called from " . caller; } warn "module Foo2's run time"; 1; # Module Foo1, file Foo1.pm package Foo1; warn "module Foo1's run time"; BEGIN { warn "module Foo1's compile time"; } sub import { warn "$_[0]\->import() called from " . caller; } warn "module Foo1's run time"; 1; # main script warn "Main script, runtime"; BEGIN { warn "Main script compile time"; } use Foo2; warn "Main script, runtime"; BEGIN { warn "Main script compile time"; }
Main script compile time at test.pl line 4. module Foo2's compile time at Foo2.pm line 4. module Foo1's compile time at Foo1.pm line 4. module Foo1's run time at Foo1.pm line 3. module Foo1's run time at Foo1.pm line 8. Foo1->import() called from Foo2 at Foo1.pm line 6. module Foo2's compile time at Foo2.pm line 6. module Foo2's run time at Foo2.pm line 3. module Foo2's run time at Foo2.pm line 10. Foo2->import() called from main at Foo2.pm line 8. Main script compile time at test.pl line 7. Main script, runtime at test.pl line 3. Main script, runtime at test.pl line 6.
As you can see, the "compile time" and "run time" messages are clearly intertwined. But one thing is for sure: import is called after the runtime for a module is completed, after the second warning for "runtime", at the end of the script, lines 8 and 10 respectively.
Conclusing: use Exporter(); or require Exporter;, it doesn't actually matter.
In reply to Re(3+): Module Inheritance
by bart
in thread Module Inheritance
by ronniec
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |