develooper Front page | perl.perl5.porters | Postings from August 2001

Re: On "Command-line Wildcard Expansion"

Thread Next
Jenda Krynicky
August 7, 2001 15:57
Re: On "Command-line Wildcard Expansion"
Message ID:
> Excerpts from the mail message of Jenda Krynicky:
> ) 
> ) > Delmonta / IIJIMA Hiromitsu wrote:
> ) > > 
> ) > >         (2) This DOES NOT expand expressions like "a:*.txt" and
> ) > >             you need to write "a:.\*.txt" instead (as of ActivePerl
> ) > >             Build #517 --- too old, yeh?).
> ) 
> ) can do better ;-)
> ) 
> )
> All I want is something that ships with Perl.  Actually, I
> find the arguments for not rolling this into Perl itself very
> unconvincing.  I'd prefer @ARGV to have wildcards expanded
> in the name of portability and provide Win32::GetCommandLine()
> for people who want to write Win32ish command-line interfaces.

Agreed completely.

> Perl already has a built-in glob(), so the arguments against
> Perl doing the glob()ing don't apply anymore.  Sure, don't
> use the C RTL command-line globber for the reasons listed.
> But, please, let's ease the confusion of those new to Perl
> under Win32 who just want some simple script to work.

Well ... I think an explanation like 

	Under Windows the wildcards passed to your scripts as parameters 
	are NOT expanded by default. You either have to do this by 
	yourself or use a module like or
	If you set PERL5OPT system variable to -MWild or -MG respectively
	those modules will expand the wildcards automatically for all 
your 	scripts."

should be sufficient unless some kind of globbing will be provided by 

> ) > This should be sufficient (at least it works for me):
> ) > 
> ) > use File::DosGlob;
> ) > @ARGV = map { File::DosGlob::glob $_ } @ARGV;
> You don't need to use File::DosGlob anymore, BTW.

Though ... just in case the script runs on an older perl ...

> ) ... if you want all parameters to be treated as file masks.
> That is a bit misleading.  glob("foo-^&#@") is "foo-^&#@"
> (at least under Win32).  

Beg your pardon???

perl -e "print glob('foo-^&#@')"
perl -e "use File::DosGlob qw(glob);print glob('foo-^&#@')"
perl -e "use File::Glob qw(glob);print glob('foo-^&#@')"

All these return NOTHING.

This is perl, v5.6.1 built for MSWin32-x86-multi-thread
Binary build 626 provided by ActiveState Tool Corp.
Built 01:31:15 May  2 2001

> And if Perl were to have built-in
> command-line glob()ing for Win32, I'd want an argument of
> "*.x" to remain "*.x" in the absence of any matching files.
> The only problem I see with the above code is that it
> _silently_ drops "*.x" from the command line.

What do Unix shells do? (I have not Unix handy so I can't check)

Besides that would be easy to change.

At 08:28 AM 8/7/2001 -0700, Gurusamy Sarathy wrote:
>I don't mind adding a thing to the distribution, perhaps
>even a single-character switch that's an alias for -MWild.
>But changing the default strikes me as a bad decision.  How are we
>going to explain the breakage to (say) bash users?

I'm not sure.
I mean ... people usually expect to get the wildcards expanded
so why couldn't it be the way they get them by default ?

Anyway .. I think a module would be handy in the 
Plus the installation/building process could ask whether I want
Unix-like parameter globing and set PERL5OPT accordingly.


P.S.: I thought I've already uploaded the new version of
that completely circumvents the broken C runtime parameter processing.
Well ... it is uploaded now if anyone wants to have a look.

== == ==
: What do people think?
What, do people think?  :-)
             -- Larry Wall in <>

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About