如何在Windows上使用Perl在命令行上处理通配符?

时间:2022-12-26 01:38:00

I though this would be simple, but apparently I can't do:

我虽然这很简单,但显然我做不到:

script.pl *.ext

in the WinXP command processor.

在WinXP命令处理器中。

Is there a built-in solution? (i.e. not a CPAN module?)

有内置的解决方案吗? (即不是CPAN模块?)

2 个解决方案

#1


File::DosGlob is a core module:

File :: DosGlob是一个核心模块:

#!/usr/bin/perl

use strict;
use warnings;

use File::DosGlob qw( glob );
print map { "$_\n"} map { glob } @ARGV;
__END__
    C:\Temp> tgh *.pl
    ...
    tgh.pl
    tgm.pl
    thg.pl
    thk.pl
    tjl.pl
    tjm.pl
    tkj.pl
    tkl.pl

#2


Use the glob function.

使用glob函数。

...returns a (possibly empty) list of filename expansions on the value of EXPR such as the standard Unix shell /bin/csh would do...

...返回一个(可能是空的)EXPR值的文件名扩展列表,例如标准的Unix shell / bin / csh会...

#1


File::DosGlob is a core module:

File :: DosGlob是一个核心模块:

#!/usr/bin/perl

use strict;
use warnings;

use File::DosGlob qw( glob );
print map { "$_\n"} map { glob } @ARGV;
__END__
    C:\Temp> tgh *.pl
    ...
    tgh.pl
    tgm.pl
    thg.pl
    thk.pl
    tjl.pl
    tjm.pl
    tkj.pl
    tkl.pl

#2


Use the glob function.

使用glob函数。

...returns a (possibly empty) list of filename expansions on the value of EXPR such as the standard Unix shell /bin/csh would do...

...返回一个(可能是空的)EXPR值的文件名扩展列表,例如标准的Unix shell / bin / csh会...