4
perl如何识别变量的结尾?在打印时,perl如何识别变量的结尾?
例如,下面的代码:
use warnings;
my $a = 10;
print "Value of a is $a:::";
输出:
Use of uninitialized value $a:: in concatenation (.) or string at tryprint.pl line 6.
Value of a is :
为什么会考虑$ A ::而不是$ A:$或一:::
这作品:
print "Value of a is $a\:::";
打印:
Value of a is 10:::
在一般情况下,凡是能在变量名中使用被解释为'$'后一个变量名。如果你想消除歧义,使用大括号;例如,打印'$ a'后面加'b',使用'print'$ {a} b“'(而不是'print'$ ab”'查找可能找不到的变量' $ ab')。 – tripleee 2013-04-18 06:58:15
哦,'Perl':'print“$ parts_ $ of_ $ file_ $ name”':( – gaussblurinc 2013-04-18 08:27:01