in reply to Fix wildcard arguments under MSWin

Oops. Forgot to log in before submitting.

This code should be placed at the very top of the script. After which @ARGV will contain what you probably expected in the first place.

Replies are listed 'Best First'.
Re^2: Fix wildcard arguments under MSWin
by Aristotle (Chancellor) on Jul 28, 2003 at 00:12 UTC
    Since there's no harm in globbing names that lack wildcards, you can skip that check. And since glob looks to $_ if missing explicitly passed parameters, you can shorten this all to
    @ARGV = map glob, @ARGV;

    Makeshifts last the longest.

      That's true.

      The test was actually there on purpose. I had scripts that I ran under MS and Unix. With the test I reduced the number of calls to glob when the command line was expanded properly. This made a significant difference in some of my code.

      I originally had an OS check in there, that I dropped when I started typing this into code. I then used the ternary test to correct for slow reactions on some Unix.

      Probably in the usual case this would be better. It's certainly easier to remember.

        You should probably instead check whether you're under Unix, and if so, not attempt to fix wildcard arguments at all. Unlike under Windows derivatives, wildcard characters are valid parts of a filename in Unix, and actual wildcards are usually already expanded by the shell. If you get a filename with what appears to be a wildcard in it, you're probably not meant to expand it.

        Makeshifts last the longest.