使 Windows 上的 Perl 像 Linux 一样工作(通配参数扩展) [英] Making Perl on Windows work like Linux (wildcarded param expansion)

查看:51
本文介绍了使 Windows 上的 Perl 像 Linux 一样工作(通配参数扩展)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于包含文件名的通配符,如果 Windows 上的 Perl 脚本能够像在 Linux 上一样工作,那就太好了.

It would be nice for Perl scripts on Windows to work like they do on Linux with regard to wildcard containing file names.

例如:

perl myscript.pl *.txt

在 Linux 上,bash 会将 *.txt 扩展为一组文件名,并将它们作为单独的参数传递给 perl 解释器.在 Windows 上,*.txt 被直接传递到 Perl.

On Linux, bash will expand the *.txt to a set of file names and pass those to the perl interpreter as individual parameters. On Windows, the *.txt gets passed directly into Perl.

所以,基本上,我正在寻找的是放在脚本顶部的东西,用于扩展通配符参数,以便脚本的其余部分可以与 Linux 上的相同.

So, basically, what I am looking for is something to put at the top of the script that will expand wildcard params, so that the rest of the script can be the same as on Linux.

例如:

myscript.pl

use warnings;
use strict;

# Mystery code to expand all wildcard params, fudging ARGV in the process
# ----
<Insert code here>
# ----

# Rest of script
...

推荐答案

  1. 安装 Win32::Autoglob 如果您Perl 没有自带.
  2. PERL5OPT 环境变量设置为-MWin32::Autoglob 或仅use Win32::Autoglob.
  1. Install Win32::Autoglob if your Perl doesn't come with it.
  2. Set the PERL5OPT environment variable to -MWin32::Autoglob or just use Win32::Autoglob.

这篇关于使 Windows 上的 Perl 像 Linux 一样工作(通配参数扩展)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆