免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2535 | 回复: 9
打印 上一主题 下一主题

关于eq与==的疑问 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-11-24 21:22 |只看该作者 |倒序浏览
想知道它们之间的区别?
>,>=,<,<=分别对应的是什么?
新手,刚看书, 碰到疑问, 请教……

[ 本帖最后由 netrookie 于 2009-11-24 21:27 编辑 ]

论坛徽章:
1
狮子座
日期:2013-12-16 16:09:24
2 [报告]
发表于 2009-11-24 21:30 |只看该作者
数字用等等,字符串用eq

论坛徽章:
0
3 [报告]
发表于 2009-11-24 21:34 |只看该作者
第二个问题?
>:gt?
>=:ge?
<:lt?
<=:le?
还有不等于!=:ne?
是吗?

论坛徽章:
1
狮子座
日期:2013-12-16 16:09:24
4 [报告]
发表于 2009-11-24 21:39 |只看该作者

论坛徽章:
0
5 [报告]
发表于 2009-11-24 21:45 |只看该作者
原帖由 netrookie 于 2009-11-24 21:34 发表
第二个问题?
>:gt?
>=:ge?


是的。
shell里数字比对用eq,字符比对用==(我记得是)。
但perl是反过来的。

论坛徽章:
0
6 [报告]
发表于 2009-11-24 21:45 |只看该作者
well, cool……
谢谢,原来还有这么个好地方。
Binary "<" returns true if the left argument is numerically less than the right argument.

Binary ">" returns true if the left argument is numerically greater than the right argument.

Binary "<=" returns true if the left argument is numerically less than or equal to the right argument.

Binary ">=" returns true if the left argument is numerically greater than or equal to the right argument.

Binary "lt" returns true if the left argument is stringwise less than the right argument.

Binary "gt" returns true if the left argument is stringwise greater than the right argument.

Binary "le" returns true if the left argument is stringwise less than or equal to the right argument.

Binary "ge" returns true if the left argument is stringwise greater than or equal to the right argument.

论坛徽章:
0
7 [报告]
发表于 2009-11-24 21:46 |只看该作者

回复 #5 兰花仙子 的帖子

不对……
Equality Operators

Binary "==" returns true if the left argument is numerically equal to the right argument.

Binary "!=" returns true if the left argument is numerically not equal to the right argument.

Binary "<=>" returns -1, 0, or 1 depending on whether the left argument is numerically less than, equal to, or greater than the right argument. If your platform supports NaNs (not-a-numbers) as numeric values, using them with "<=>" returns undef. NaN is not "<", "==", ">", "<=" or ">=" anything (even NaN), so those 5 return false. NaN != NaN returns true, as does NaN != anything else. If your platform doesn't support NaNs then NaN is just a string with numeric value 0.

   1. perl -le '$a = "NaN"; print "No NaN support here" if $a == $a'
   2. perl -le '$a = "NaN"; print "NaN support here" if $a != $a'

Binary "eq" returns true if the left argument is stringwise equal to the right argument.

Binary "ne" returns true if the left argument is stringwise not equal to the right argument.


[ 本帖最后由 netrookie 于 2009-11-24 21:47 编辑 ]

论坛徽章:
0
8 [报告]
发表于 2009-11-25 15:24 |只看该作者
和shell相反。

论坛徽章:
0
9 [报告]
发表于 2009-11-25 15:29 |只看该作者
都是perl的类型系统惹的祸  

论坛徽章:
0
10 [报告]
发表于 2009-11-26 15:50 |只看该作者
原帖由 netrookie 于 2009-11-24 21:22 发表
想知道它们之间的区别?
>,>=,


> gt  greater than
< lt   less than
>= ge  greater equal
<= le    less equal

英文不知道对不对...
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP