如何使用Perl Glob读取远程位置? [英] How to use Perl glob to read remote location?
本文介绍了如何使用Perl Glob读取远程位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的测试脚本:
my $loc = "\\\\ant\\d1_sp\\test__18716093";
####$loc = "c:\\temp"; #this works good if I un-comment.
system("dir $loc\\*.log"); #added system command just for debugging.
my @test = glob qq("$loc\\*.log");
print "\narray=@test\n";
我想将 $ loc 中的文件名保存到数组中以进行进一步处理,但是这样做没有,我缺少什么?输出是:
I want to save the file names in $loc into array for further processing, but its not doing so, what am I missing? output is:
C:\>perl c:\temp\foo.pl
Directory of \\ant\d1_sp\test__18716093
03/14/2016 01:09 PM 959 build_1.8980.log
03/14/2016 01:20 PM 102,402 build_2.98981.log
2 File(s) 103,361 bytes
0 Dir(s) 1,589,522,239,488 bytes free
array=
C:\>
推荐答案
您要在以下共享中列出.log
文件:
You want to list the .log
files in the following share:
\\ant\d1_sp\test__18716093
为此,您需要使用以下glob模式:
To do so, you need to use the following glob pattern:
\\\\ant\\d1_sp\\test__18716093\\*.log
以下是产生该字符串的字符串文字:
The following is a string literal that produces that string:
"\\\\\\\\ant\\\\d1_sp\\\\test__18716093\\\\*.log"
解决方案是
glob("\\\\\\\\ant\\\\d1_sp\\\\test__18716093\\\\*.log")
最好只使用/
而不是\
,因为您无需以全局模式或字符串文字对其进行转义.
Best to just use /
instead of \
since you don't need to escape it in either glob patterns or string literals.
glob("//ant/d1_sp/test__18716093/*.log")
这篇关于如何使用Perl Glob读取远程位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文