Username: Password:

perl实例分析教程之四
来源:linux宝库作者:linux宝库 发布时间:2007-09-30 00:00:00


  十一、操作符的次序

  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、用多行、空格等方式提高程式的可读性。

喜欢本文,那就收藏到:

    Del.icio.us Google书签 Digg Live Bookmark Technorati Furl Yahoo书签 Facebook 百度搜藏 新浪ViVi 365Key网摘 天极网摘 和讯网摘 博拉网 POCO网摘 添加到饭否 QQ书签 Digbuzz我挖网
相关评论  我也要评论
还没有关于此文章的相关评论!
  • 昵称: (为空则显示guest)
  • 评论分数: ★ ★ ★★★ ★★★★ ★★★★★
  • 评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
  • 导航
    赞助商
    文章类别
    订阅