无法在Windows Platform中使用Perl列出目录(包括空间) [英] Can NOT List directory including space using Perl in Windows Platform

查看:67
本文介绍了无法在Windows Platform中使用Perl列出目录(包括空间)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了列出Windows中的路径,我在Perl函数下面编写了代码(在StrawBerry运行时环境下执行).

In order to list pathes in Windows,I wrote below Perl function(executed under StrawBerry runtime environment).

sub listpath
{
   my $path = shift;
   my @list = glob "$path/*";
   #my @list = <$path/*>;
   my @pathes = grep {  -d and $_ ne "." and $_ ne ".." } @list;
}

但是它不能正确解析包含空间的目录,例如:

But it can't parse directory including space correctly, for example:

当我发出以下代码时: listpath("e:/test/test1/test11/test111/test1111/test11111-复制");

When I issued following code: listpath("e:/test/test1/test11/test111/test1111/test11111 - Copy");

该函数返回了一个包含两个元素的数组:

The function returned an array including two elements:

1:e:/test/test1/test11/test111/test1111/test11111 2:-

1: e:/test/test1/test11/test111/test1111/test11111 2: -

我想知道glob是否可以解析空间目录上方的内容.非常感谢.

I am wondering if glob could parse above space directories. Thanks a lot.

推荐答案

请尝试 bsd_glob 代替:

Try bsd_glob instead:

use File::Glob ':glob';
my @list = bsd_glob "$path/*";

这篇关于无法在Windows Platform中使用Perl列出目录(包括空间)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆