[问题] eval for string

楼主: sixth (冲向世界的最高峰)   2019-07-19 10:12:51
请问如何让范例2 像 范例1 一样,印出计算结果?
范例1:
eval '$sum = ((0x1 << 8) -1)';
print "The sum is $sum\n";
==> 会印出 255
范例2:
$str_test = "((0x1 << 8) -1)";
eval '$sum = $str_test';
print "The sum is $sum\n";
==> 会印出 (0x1 << 8) -1)

Links booklink

Contact Us: admin [ a t ] ucptt.com