http://www.perlmonks.org?node_id=127605


in reply to Re: Re: Trojan Horse? (taint mode)
in thread Trojan Horse? (taint mode)

I see no difference in the behavior of the following two lines:
$a = qq|${system("echo 'hello from system'")}\n|; $a = "${system(\"echo 'hello from system'\")}\n";
They both execute the 'echo' command which sends a message to your terminal and returns 0. My perl (5.00503 and 5.6.1 on unix) then complains that 0 is not a scalar ref and dies. Apparently your perl is casting the return value of 0 into a scalar ref to 0, and $a is assigned the value of $0, which happens to be the name of the script.

The book seems to imply that this behavior emulates what would happen if $a had come from user input. Fortunately that is not the case. If $a had come from STDIN, none of the above caveats would apply. Try it:

#!/usr/bin/perl -wT use strict; my $a = <STDIN>; chomp($a); print "$a";
</code>

-Blake