in reply to Re^4: When C<use Module;> *not* the same as C<require Module; import Module;>?
in thread When C<use Module;> *not* the same as C<require Module; import Module;>?
No, that was deliberate. There would be no point in not using use if I did. The whole point is to defer the loading of the module until and if it is needed.
That's exactly the problem. Some of the benefits of "use"ing a module can only be observed when it is done at compile time. This is particularly important when prototypes are involved. For example, the Test::Exception module uses prototypes to allow you to use this syntax:
dies_ok {$foo->method1} 'expecting to die'; For one of my modules, I wanted to use Test::Exception in an eval so that I could skip the tests if Test::Exception was not installed. It didn't work (with the syntax shown above) until I wrapped the eval in a BEGIN block.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: When C<use Module;> *not* the same as C<require Module; import Module;>?
by BrowserUk (Patriarch) on Jan 08, 2005 at 18:12 UTC | |
by chromatic (Archbishop) on Jan 08, 2005 at 20:58 UTC | |
by itub (Priest) on Jan 08, 2005 at 23:25 UTC | |
by BrowserUk (Patriarch) on Jan 08, 2005 at 23:48 UTC | |
|
Re^6: When C<use Module;> *not* the same as C<require Module; import Module;>?
by adrianh (Chancellor) on Jul 26, 2005 at 17:53 UTC |