将有人请解释下一个:
在“Programming Perl”一书中,postfix autoincrement operator被描述为
when placed after,they (
$a--
,$a++
) increment or decrement the variable after returning the value.
所以,据我所知,$a从未在虚空环境中使用过,因为有人说过
they increment or decrement the variable
但在下一个示例中,变量的值永远不会改变:
my $a = 3; $a = $a++; say $a; #always outputs 3
所以我的假设是当将值赋给同一个变量时没有理由使用后自动递增,但是“编程Perl”中的定义应该被认为是错误的,因为运算符不会影响变量,而是变量中的值(至少在那个例子中).是对的吗?
提前欣赏.