【问题标题】:Is there a Perl module that works similarly to the Unix "which" command? [closed]是否有类似于 Unix 的“which”命令的 Perl 模块? [关闭]
【发布时间】:2010-11-17 00:22:46
【问题描述】:

我在 Perlmonks 上发现了这个很棒的清单:

http://www.perlmonks.org/?node_id=627015

但它缺少“which”,即在 PATH 中的所有目录中搜索可执行文件的函数。 (我正在将 Perl 脚本移植到 Windows。)

是否有模拟这个的 Perl 模块?

【问题讨论】:

  • PerlPowerTools 中还有一个which,我有我自己的工具,我称之为rhich,它可以完成类似的工作,但使用正则表达式来匹配程序。

标签: perl unix


【解决方案1】:

File::Which。始终检查 CPAN! :)

【讨论】:

  • 谢谢。 Google 让我失望了,因为“which”是一个常用词,而我得到的只是搜索中的垃圾。
  • 好吧,既然可以使用 CPAN 搜索 (search.cpan.org),为什么还要使用 Google。在 www.cpan.org 上很难找到东西。
  • File::Which::which 文档说它是“作为 API 的 which 实用程序的 Perl 实现”。但是,在 1.09 版中,调用 File::Which::which("/bin/ls") 会返回 undef。从 *nix shell 调用“which /bin/ls”会返回“/bin/ls”。
【解决方案2】:

你看过这个片段吗?

which (for Windows) in pure perl

后续指向CPAN上的模块File::Which

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2013-10-27
  • 2018-03-15
  • 2015-05-15
  • 2014-01-13
  • 2012-12-13
  • 1970-01-01
  • 1970-01-01
  • 2010-09-23
相关资源
最近更新 更多