为什么 Perl 在工作 Windows 目录中看不到我的文件?

Why doesn't Perl see my file in the working Windows directory?

提问人:Hack-R 提问时间:4/21/2016 更新时间:4/21/2016 访问量:362

问:

我使用的是 Strawberry Perl 和 Windows Server 2008 的当前版本。

由于某种原因,Perl 似乎在当前工作目录中找不到文件:

F:\temp\hackr\e>ls
test.csv      train.csv

F:\temp\hackr\e>perl -ne 'print if (rand() < .01)' train.csv
The system cannot find the file specified.
Perl的

评论

1赞 simbabque 4/21/2016
你确定它找到了吗?perl
0赞 Hack-R 4/21/2016
@simbabque 问得好。当我只是输入并输入时,没有错误。它会下行等待进一步的命令。所以我认为它找到了perl。perl

答:

7赞 mob 4/21/2016 #1

在 Windows 命令行上,在需要引号的命令行参数周围使用双引号。

perl -ne "print if (rand() < .01)" train.csv

评论

0赞 Borodin 4/21/2016
@Hack-R:Linux 在命令行上接受双引号或单引号(具有不同的行为),但 Windows 坚持使用双引号