免费注册 查看新帖 |

Chinaunix

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

glob的排序根据 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-11-27 17:22 |只看该作者 |倒序浏览
请教:glob是通过哪种方式,access,modify,还是change时间戳对得到的文件排序的?

论坛徽章:
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
2 [报告]
发表于 2014-11-27 20:55 |只看该作者
回复 1# qxt912

$ perldoc -f glob
    glob EXPR
    glob    In list context, returns a (possibly empty) list of filename
            expansions on the value of EXPR such as the standard Unix shell
            /bin/csh would do. In scalar context, glob iterates through such
            filename expansions, returning undef when the list is exhausted.
            This is the internal function implementing the "<*.c>" operator,
            but you can use it directly. If EXPR is omitted, $_ is used. The
            "<*.c>" operator is discussed in more detail in "I/O Operators" in
            perlop.

            Note that "glob" splits its arguments on whitespace and treats
            each segment as separate pattern. As such, "glob("*.c *.h")"
            matches all files with a .c or .h extension. The expression
            "glob(".* *")" matches all files in the current working directory.

            If non-empty braces are the only wildcard characters used in the
            "glob", no filenames are matched, but potentially many strings are
            returned. For example, this produces nine strings, one for each
            pairing of fruits and colors:

                @many =  glob "{apple,tomato,cherry}={green,yellow,red}";

            Beginning with v5.6.0, this operator is implemented using the
            standard "File::Glob" extension. See File::Glob for details,
            including "bsd_glob" which does not treat whitespace as a pattern
            separator.
   

论坛徽章:
0
3 [报告]
发表于 2014-12-05 15:06 |只看该作者
回复 2# jason680


    具体那句话写出了glob 排序的根据。。

论坛徽章:
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
4 [报告]
发表于 2014-12-05 16:09 |只看该作者
回复 3# qxt912

glob without sort
   

论坛徽章:
1
处女座
日期:2014-03-28 10:11:00
5 [报告]
发表于 2014-12-16 19:59 |只看该作者
完全可以读入到数组以后,按照你自己想要的方式排序。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP