免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: slwj
打印 上一主题 下一主题

PERL两个字符串,不关心大小写 [复制链接]

求职 : 软件工程师
论坛徽章:
3
程序设计版块每日发帖之星
日期:2015-10-07 06:20:00程序设计版块每日发帖之星
日期:2015-12-13 06:20:00程序设计版块每日发帖之星
日期:2016-05-05 06:20:00
11 [报告]
发表于 2014-04-02 21:00 |只看该作者
Perl新的版本可能要废除 $_ ,代码不但是用来运行的,还是给未来的自己看的。

论坛徽章:
0
12 [报告]
发表于 2014-04-03 12:24 |只看该作者
lc($one) eq lc($two)
lc什么意思?

论坛徽章:
145
技术图书徽章
日期:2013-10-01 15:32:13戌狗
日期:2013-10-25 13:31:35金牛座
日期:2013-11-04 16:22:07子鼠
日期:2013-11-18 18:48:57白羊座
日期:2013-11-29 10:09:11狮子座
日期:2013-12-12 09:57:42白羊座
日期:2013-12-24 16:24:46辰龙
日期:2014-01-08 15:26:12技术图书徽章
日期:2014-01-17 13:24:40巳蛇
日期:2014-02-18 14:32:59未羊
日期:2014-02-20 14:12:13白羊座
日期:2014-02-26 12:06:59
13 [报告]
发表于 2014-04-03 13:33 |只看该作者
本帖最后由 jason680 于 2014-04-03 13:34 编辑

回复 12# qianyemlf

$ perldoc -f lc
    lc EXPR
    lc      Returns a lowercased version of EXPR. This is the internal
            function implementing the "\L" escape in double-quoted strings.

            If EXPR is omitted, uses $_.


$ perldoc -f uc
    uc EXPR
    uc      Returns an uppercased version of EXPR. This is the internal
            function implementing the "\U" escape in double-quoted strings. It
            does not attempt to do titlecase mapping on initial letters. See
            "ucfirst" for that.

            If EXPR is omitted, uses $_.

            This function behaves the same way under various pragma, such as
            in a locale, as "lc" does.

论坛徽章:
1
双子座
日期:2013-11-06 17:18:01
14 [报告]
发表于 2014-04-03 13:42 |只看该作者
回复 11# 104359176


    废除$_,那之前的代码是否不兼容阿。

论坛徽章:
46
15-16赛季CBA联赛之四川
日期:2018-03-27 11:59:132015年亚洲杯之沙特阿拉伯
日期:2015-04-11 17:31:45天蝎座
日期:2015-03-25 16:56:49双鱼座
日期:2015-03-25 16:56:30摩羯座
日期:2015-03-25 16:56:09巳蛇
日期:2015-03-25 16:55:30卯兔
日期:2015-03-25 16:54:29子鼠
日期:2015-03-25 16:53:59申猴
日期:2015-03-25 16:53:29寅虎
日期:2015-03-25 16:52:29羊年新春福章
日期:2015-03-25 16:51:212015亚冠之布里斯班狮吼
日期:2015-07-13 10:44:56
15 [报告]
发表于 2014-04-03 14:24 |只看该作者
不建议的是 my $_,这是个错误的实践,并不是要废除默认参数的用法。 5.18 文档中
Lexical $_ is now experimental

Since it was introduced in Perl v5.10, it has caused much confusion with no obvious solution:

    Various modules (e.g., List::Util) expect callback routines to use the global $_. use List::Util 'first'; my $_; first { $_ == 1 } @list does not work as one would expect.
    A my $_ declaration earlier in the same file can cause confusing closure warnings.
    The "_" subroutine prototype character allows called subroutines to access your lexical $_, so it is not really private after all.
    Nevertheless, subroutines with a "(@)" prototype and methods cannot access the caller's lexical $_, unless they are written in XS.
    But even XS routines cannot access a lexical $_ declared, not in the calling subroutine, but in an outer scope, iff that subroutine happened not to mention $_ or use any operators that default to $_.

It is our hope that lexical $_ can be rehabilitated, but this may cause changes in its behavior. Please use it with caution until it becomes stable.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP