cogent has asked for the wisdom of the Perl Monks concerning the following question:

When I first discovered that there was a taint option to use warnings, I was pretty jazzed at the ability to lexically turn on and off data tainting. Not that I knew why such a thing would be useful, but it just seemed cool. So I tried it:

#! /usr/bin/perl use strict; use warnings FATAL => qw(taint); my $tainted = shift; open (OUCH, "> $tainted"); close (OUCH);

Nay. The filename passed on the command name was used; the file was created. I tried both with and without the FATAL => part, as I'd found in perldoc perllexwarn.

Then it occurred to me that perhaps no warnings qw(taint); might work to block the -T switch. Nay again.

So now I wonder what the heck taint is doing in the use warnings tree at all.

Replies are listed 'Best First'.
Re: use warnings qw(taint);
by Fastolfe (Vicar) on Jan 05, 2001 at 08:25 UTC
    Not all tainting "violations" are fatal with -T. Some of them are simply warnings. The only one I'm familiar with is using chdir with a tainted argument, but there may be others. Saying "no warnings 'taint';" will shut these off in case you want to ignore them.