4

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

script.pl *.ext

in the WinXP command processor.

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

Sinan Ünür
  • 116,958
  • 15
  • 196
  • 339
chris
  • 36,094
  • 53
  • 157
  • 237

2 Answers2

5

File::DosGlob is a core module:

#!/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
Sinan Ünür
  • 116,958
  • 15
  • 196
  • 339
4

Use the glob function.

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

spoulson
  • 21,335
  • 15
  • 77
  • 102
  • 3
    But *only* use it on Windows. If you use it on Unix, you risk globbing real file names; asterisks and question marks are valid characters in Unix file names. – Rob Kennedy Jul 14 '09 at 14:54