Perl Advent Calendar 2010-12-15

$HOME for the holidays

by Jerrad Pierce

You're probably aware that saintly coders don't use tained data, but were you aware that you should also clean your environment? Env::Sanctify simplifies the process of cleaning %ENV with regular expressions, and restoring it later. If you're only mildly concerned with security, or unsure where to begin, Env::Sanctify::Auto will delint your environment automatically.

% perl -MEnv::Sanctify::Auto -e 'my $env = Env::Sanctify::Auto->new(); print `env`'
…
VISUAL=emacs
HOME=/home/kringle
GROUP=kringle
SHELL=/bin/tcsh
PATH=/usr/bin:/usr/bin/local
% env
…
VISUAL=emacs
HOME=/home/kringle
GROUP=kringle
SHELL=/bin/tcsh
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games
View Source (POD)