Author image Brian McCauley (PAUSE Custodial Account)


perl5lib - Honour PERL5LIB even in taint mode.


    #!/usr/bin/perl -T
    use perl5lib;
    use My::Other::Module; # In directory listed in PERL5LIB


Perl's taint mode was originally intended for setuid scripts. In that situation it would be unsafe for Perl to populate @INC from $ENV{PERL5LIB}. The explicit -T flag is now often used in CGI scripts and suchlike. In such situations it often makes sense to consider $ENV{PERL5LIB} as untainted.

This module uses the lib module to simulate the effect of non-taint mode Perl's default handling of $ENV{PERL5LIB}.

As a side effect any directories in $ENV{PERL5LIB} are brought to the front of @INC. Occasionally this may be useful if one needs an explict use lib for a project but one still wants development versions in one's personal module directory to override.


The programmer is responsible for deciding if it really is safe to consider $ENV{PERL5LIB} to be untainted in the enviroment where the script is to be used. For example, using this module in a setuid script would be a big mistake.

For this reason, this module should not be used by other modules, only directly by scripts.


Brian McCauley <>.