为什么Perl中的'print(52-80)* 42'与'print 42 *(52-80)'不同? [英] Why is 'print (52-80)*42' different than 'print 42*(52-80)' in Perl?
本文介绍了为什么Perl中的'print(52-80)* 42'与'print 42 *(52-80)'不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Perl ::什么是:
Perl:: What is:
1. (52-80)*42
2. 42*(52-80)
回答:
1. -28
2. -1176
为什么?
请乐于解释/证明这一点!
Have fun explaining/justifying this please!
#!/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;
您会得到:
If you add use warnings;
you'll get:
print (...) interpreted as function at ./test.pl line 5.
Useless use of a constant in void context at ./test.pl line 5
这篇关于为什么Perl中的'print(52-80)* 42'与'print 42 *(52-80)'不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文