Perl ::什么是:
1. (52-80)*42 2. 42*(52-80)
答:
1. -28 2. -1176
为什么?
请乐趣解释/证明这一点!
#!/usr/bin/perl use strict; print 42*(52-80),"\n"; print ((52-80)*42),"\n"; print (52-80)*42,"\n"; print "\n"; my $i=(52-80)*42; print $i,"\n";
输出:
> -1176 > -1176-28 > -1176
解决方法
如果您添加
use warnings;
,您将获得:
print (...) interpreted as function at ./test.pl line 5. Useless use of a constant in void context at ./test.pl line 5