Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

drhyde (1683)

  (email not shown publicly)

Journal of drhyde (1683)

Wednesday April 25, 2007
09:41 AM

Preventing modules from loading

[ #33099 ]

$ perl -Ilib -MNo=Data::Dumper -e 'use Data::Dumper'
Data::Dumper isn't allowed to load.
Compilation failed in require.
BEGIN failed--compilation aborted.

This is actually useful. Imagine you've written some code which, if some optional module is present, will do different stuff. You need to test both with and without the optional module before releasing your code. The usual way to do that is to monkey around in your perl libs and temporarily rename the appropriate .pm file or something like that so that perl can't "see" it. That sucks.

With this cunning trick, simply use No qw(Some::Random::Module) in a test file and the effect will be as if it wasn't there.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.