Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: How to expand wildcard arguments supplied to programs with perl on windows?

by atcroft (Monsignor)
on Aug 17, 2012 at 02:02 UTC ( #987902=note: print w/ replies, xml ) Need Help??


in reply to How to expand wildcard arguments supplied to programs with perl on windows?

I don't know about the Wild.pm module you were using, but I was able to get results similar to what you indicated you expected with the following code:

use strict; use warnings; foreach my $pattern (@ARGV) { foreach (glob($pattern)) { print qq{$_\n}; } }

This was called from a Windows Command Prompt using Strawberry Perl as follows: perl test.pl *.txt I used a loop for @ARGV to allow for multiple patterns to be specified on the command line, to give a little extra flexibility.

Hope that helps.


Comment on Re: How to expand wildcard arguments supplied to programs with perl on windows?
Select or Download Code
Re^2: How to expand wildcard arguments supplied to programs with perl on windows?
by andalou (Novice) on Aug 17, 2012 at 02:19 UTC

    Thanks, but it doesn't work if a file has Chinese characters in its
    filename, as in song自然之歌.txt

      The Perl file system calls and Unicode don't mix particularly well on file systems that don't encode their filenames as UTF-8. See for example Check if unicode directory exists.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://987902]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2014-07-10 21:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (216 votes), past polls