【问题标题】:Why doesn't Perl see my file in the working Windows directory?为什么 Perl 在工作 Windows 目录中看不到我的文件?
【发布时间】:2016-04-21 22:30:34
【问题描述】:

我正在使用当前版本的 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
  • @simbabque 好问题。当我输入perl 并输入时,没有错误。它放下一行等待进一步的命令。所以我认为它找到了 perl。

标签: perl


【解决方案1】:

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

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

【讨论】:

  • @Hack-R:Linux 将在命令行上接受双引号或单引号(具有不同的行为),但 Windows 坚持使用双引号
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多