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

Hi, For a program that has to run on Perl 5.6.1 i need to detect if taint mode is on or not. In perl 5.8.6 i see in perlvar that there is a variable to check this, ${^TAINT} . How can this be done in perl 5.6.1? thanks

Replies are listed 'Best First'.
Re: detect taint mode in Perl 5.6.1
by JavaFan (Canon) on Mar 24, 2011 at 11:20 UTC
    I don't have 5.6.1 handy, but this seems to work in 5.6.2, so it may work in 5.6.1 as well:
    $ perl -T -MScalar::Util=tainted -wle 'print tainted $0 ? "Taint mode +on" : "Taint mode off"' Taint mode on $ perl -MScalar::Util=tainted -wle 'print tainted $0 ? "Taint mode +on" : "Taint mode off"' Taint mode off $
    And if in 5.6.1 Scalar::Util doesn't have tainted, something like:
    $ perl -Twle 'eval {open my $fh, "+>$0"}; print $@ =~ /Insecure/ ? "Ta +int mode on" : "Taint mode off"' Taint mode on $ perl -wle 'eval {open my $fh, "+>$0"}; print $@ =~ /Insecure/ ? "Ta +int mode on" : "Taint mode off"' Taint mode off $