免费注册 查看新帖 |

Chinaunix

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

win下哪个模块查找文件最好用? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-11-05 15:31 |只看该作者 |倒序浏览
原来一直使用 file::find,最近发现它遇到windows的超长文件名时会出错,导致整个perl退出,请问各位觉得哪个文件查找模块最好用?

论坛徽章:
0
2 [报告]
发表于 2009-11-06 00:54 |只看该作者

回复 #1 justin764 的帖子

Using Win32::OLE and call WSH/VBS Object such as "Scripting.FileSystemObject".

sample code:

  1. use strict;
  2. use warnings;
  3. use Win32::OLE qw/in/;

  4. my $searchDir = "C:\\temp";
  5. my $objFolder = $fso->GetFolder($searchDir);

  6. sub findFile {
  7.     my ($objFolder, $searchPattern) = @_;
  8.     my $colFolders = $objFolder->SubFolders();
  9.    
  10.    
  11.     foreach my $objSubFolder (in $colFolders) {
  12.         # processing folder        
  13.         ...
  14.         foreach my $objFile (in $colFiles) {
  15.             # processing file
  16.             ...
  17.             #  regexp pattern
  18.            }
  19.         }
  20.         # print result
  21.         ....
  22.         # recursive
  23.         findFile($objSubFolder, $searchPattern);
  24.     }
  25. }

  26. # main
  27. findFile($objFolder, qr /.inf$/i);

复制代码

评分

参与人数 1可用积分 +3 收起 理由
兰花仙子 + 3 我很赞同

查看全部评分

论坛徽章:
0
3 [报告]
发表于 2009-11-06 09:20 |只看该作者

回复 #2 ulmer 的帖子

ulmer is right.
I do remember there is such a module doing that, but I forgot the name.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP