# check whether or not a scalar variable is tainted # (code straight from the Camel, 3rd ed., page 561) sub is_tainted_pp { my $arg = shift; my $nada = substr( $arg, 0, 0 ); # zero-length local $@; eval { eval "# $nada" }; return length($@) != 0; } # We need a function that checks if a scalar is tainted. # Either use the # Scalar::Util module's tainted() function # or our (slower) pure Perl # fallback is_tainted_pp() { local $@; eval { require Scalar::Util }; *is_tainted = $@ ? \&is_tainted_pp : \&Scalar::Util::tainted; }