#!/usr/bin/perl -T use warnings; use strict; use Scalar::Util qw/tainted/; # Note: $t is tainted my $t = "purple" . substr($^X,0,0); my $foo = "blah"; my $bar = "foo: $foo"; my $one; $one = $t ? "the $foo" : $bar; print "1. tainted\n" if tainted($one); my $two; $two = $t ? "the foo" : $bar; print "2. tainted\n" if tainted($two); my $three; if ($t) { $three = "the $foo"; } else { $three = $bar; } print "3. tainted\n" if tainted($three); my $four; if ($t) { $four = "the foo"; } else { $four = $bar; } print "4. tainted\n" if tainted($four); print "5. tainted\n" if tainted($bar); print "6. tainted\n" if tainted("the $foo"); my $seven = ""; $seven = "the $foo" if $t; print "7. tainted\n" if tainted($seven);