阅读内容 

perl实例分析教程之四

[日期:2005-04-13] 来源:中国站长学院  作者:郁郁小蝎 [字体: ]
十一、操作符的次序

Table 3.6. 操作符次序
操作符 描述

++, -- 自增,自减
-, ~, ! 单目
** 乘方
=~, !~ 模式匹配
*, /, %, x 乘,除,取余,重复
+, -, . 加,减,联接
<<, >> 移位
-e, -r, etc. 文件状态
<, <=, >, >=, lt, le, gt, ge 不等比较
==, !=, <=>, eq, ne, cmp 相等比较
& 位与
|, ^ 位或,位异或
&& 逻辑与
|| 逻辑或
.. 列表范围
? and : 条件操作符
=, +=, -=, *=, 赋值
and so on  
, 逗号操作符
not Low-precedence logical NOT
and Low-precedence logical AND
or, xor Low-precedence logical OR and XOR

.操作符结合性(associativity):

Table 3.7. 操作符结合性

操作符 结合性
++, -- 无
-, ~, ! Right-to-left
** Right-to-left
=~, !~ Left-to-right
*, /, %, x Left-to-right
+, -, . Left-to-right
<<, >> Left-to-right
-e, -r, 无
<, <=, >, >=, lt, le, gt, ge Left-to-right
==, !=, <=>, eq, ne, cmp Left-to-right
& Left-to-right
|, ^ Left-to-right
&& Left-to-right
|| Left-to-right
.. Left-to-right
? and : Right-to-left
=, +=, -=, *=, Right-to-left
and so on  
, Left-to-right
not Left-to-right
and Left-to-right
or, xor Left-to-right

建议:
1、当你不确定某操作符是否先执行时,一定要用括号明确之。
2、用多行、空格等方式提高程序的可读性。
阅读:
录入:

推荐 】 【 打印
相关新闻      
本文评论       全部评论
发表评论
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款


点评: 字数
姓名:
Advertisement
内容查询


Advertisement