Introducing lib::filter

lib::filter is a pragma that can help you while debugging your applications by simulating the absence of some modules. You can:

  • Test your application using only core modules (this is basically the same as using lib::core::only):
    % perl -Mlib::filter=allow_noncore,0
  • Assume only core modules plus some other modules exist (separate the modules to allow using semicolon):
    % perl -Mlib::filter=allow_noncore,0,allow,'Foo;Bar::Baz;Qux'
  • Assume some modules do not exist:
    % perl -Mlib::filter=disallow,'YAML::XS;YAML::Syck'

Note that, as an alternative to using -M... perl option directly, you can also use PERL5OPT. This has the advantage of not having to call perl explicitly e.g.:

% PERL5OPT="-Mlib::filter=allow_noncore,0"

Also, in addition to specifying list of modules to allow/disallow directly, you can also specify them in a file and refer the file. To do that, replace the ‘allow’ or ‘disallow’ parameter with ‘allow_list’ or ‘disallow_list’, respectively. For example:

% perl -Mlib::filter=disallow_list,/tmp/disallow.txt

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s