WithABeard has asked for the wisdom of the Perl Monks concerning the following question:
It seems that perl doesn't glob arguments on windows.
Output in windows command prompt:
c:\scratch>dir /B file1 file2 file3 c:\scratch>perl -wnl -e "BEGIN{ print qq(Arguments: @ARGV); exit; }" * Arguments: * c:\scratch>|
compared to output in a linux shell:
Linux > ls file1 file2 file3 Linux > perl -wnl -e 'BEGIN { print "Arguments: @ARGV"; exit; }' * Arguments: file1 file2 file3 Linux > |
A little annoying when I want to use my scripts on both linux and windows.
I solved it with a tiny module in my home directory:
package Glob::Auto; use strict; BEGIN { @ARGV or return; # done if no arguments @ARGV = map { -e ? $_ : glob $_ } @ARGV; # glob anything that d +oesn't exist } 1;
So I simply add use Glob::Auto; to my script, and it works the same on windows as on linux.
Has anyone experienced the same? Any other solutions?
Could it be a bug? I am using Strawberry Perl version 5.32
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: globbing arguments on windows
by haukex (Archbishop) on Jan 16, 2023 at 12:12 UTC | |
by WithABeard (Beadle) on Jan 16, 2023 at 12:18 UTC | |
by Discipulus (Canon) on Jan 16, 2023 at 12:37 UTC | |
|
Re: globbing arguments on windows
by hv (Prior) on Jan 16, 2023 at 11:27 UTC | |
|
Re: globbing arguments on windows
by WithABeard (Beadle) on Jan 16, 2023 at 11:28 UTC |