这有什么做用Perl。您传递给dir
的参数不正确。
dir
解释/
作为一个选项的开始,除非它的报价,
- 你必须在不应该出现在路中间的空间,
/s
不工作的路径包含/
和一个文件组件。
此外,除了/s
之外,您可能还需要/b
。
修正:
dir "\\server1\dxx\mxx\rxx\ui.xml" /s/b
所以
my $dir_output = `dir "\\\\server1\\dxx\\mxx\\rxx\\ui.xml" /s/b`;
例,
>dir "//localhost/C$/Users/ikegami/Desktop/" /s/b
\\localhost\C$\Users\ikegami\Desktop\a.jpg
\\localhost\C$\Users\ikegami\Desktop\cabinet.txt
...
>dir "//localhost/C$/Users/ikegami/Desktop/a.jpg" /s/b
File Not Found <-- WTF?
>dir "\\localhost\C$\Users\ikegami\Desktop\a.jpg" /s/b
\\localhost\C$\Users\ikegami\Desktop\a.jpg
\\localhost\C$\Users\ikegami\Desktop\x\a.jpg
>dir \\localhost\C$\Users\ikegami\Desktop\a.jpg /s/b
\\localhost\C$\Users\ikegami\Desktop\a.jpg
\\localhost\C$\Users\ikegami\Desktop\x\a.jpg
>type a.pl
print `dir \\\\localhost\\C\$\\Users\\ikegami\\Desktop\\a.jpg /s/b`
>perl a.pl
\\localhost\C$\Users\ikegami\Desktop\a.jpg
\\localhost\C$\Users\ikegami\Desktop\x\a.jpg
这么说,我会亲自使用File::Find::Rule。
use File::Find::Rule qw();
my $qfns =
File::Find::Rule
->name('ui.xml')
->file
->in('//server1/dxx/mxx/rxx');
这是在Windows上吗?你可能需要反斜杠。 – simbabque
@simbabque是windows,我不能写反斜杠,cmd中的cygwin工具要求我写相当于posix的命令时,我能够使用正斜杠列出rxx文件夹中的所有文件,但是我不能递归查找文件,因为'/ s'参数被解释为文件路径 – PopCorn
将开关置于路径之前。 – simbabque