如果 Windows 上的 Perl 脚本在包含文件名的通配符方面能够像在 Linux 上一样工作,那就太好了。
例如:
perl myscript.pl *.txt
在 Linux 上,bash 会将 *.txt 扩展为一组文件名,并将它们作为单独的参数传递给 perl 解释器。在 Windows 上,*.txt 直接传递到 Perl 中。
所以,基本上,我正在寻找的是放在脚本顶部的东西,它将扩展通配符参数,以便脚本的其余部分可以与 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
...
- Install Win32::Autoglob http://search.cpan.org/perldoc?Win32%3a%3aAutoglob如果你的 Perl 没有附带。
- Set the
PERL5OPT
环境变量为-MWin32::Autoglob
要不就use Win32::Autoglob
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)