DOS: command line wildcards 
Author Message
 DOS: command line wildcards

Hi,

I'm new to perl - finally upgrading from awk! Running: Perl, version 4.0; DOS
After looking through the WCS text, and attempting to get the FAQ, I now
turn to you, dear (news) reader-

I want to say something like:
        perl -n test.pl *.dat

but the wildcard does not seem to be expanded into all the matching
filenames! This is a fundamental feature of tools like grep and awk -
how do I get perl to do it?

I tried
        while (<*>) {print;}
as a test example, and it doesn't seem to work either. (Also, a few other
glob() tests...)

Thanks!
--
Brendan Macmillan



Mon, 10 Jul 2000 03:00:00 GMT  
 DOS: command line wildcards

in dos, something like the following ought to work from the commandline:

for %a in (*.dat) do perl -n test.pl %a

hth.

steve


Quote:
>Hi,

>I'm new to perl - finally upgrading from awk! Running: Perl, version 4.0;
DOS
>After looking through the WCS text, and attempting to get the FAQ, I now
>turn to you, dear (news) reader-

>I want to say something like:
> perl -n test.pl *.dat

>but the wildcard does not seem to be expanded into all the matching



Mon, 10 Jul 2000 03:00:00 GMT  
 DOS: command line wildcards



Quote:

>Hi,

>I'm new to perl - finally upgrading from awk! Running: Perl, version 4.0;
DOS
>After looking through the WCS text, and attempting to get the FAQ, I now
>turn to you, dear (news) reader-

>I want to say something like:
>        perl -n test.pl *.dat

>but the wildcard does not seem to be expanded into all the matching
>filenames! This is a fundamental feature of tools like grep and awk -
>how do I get perl to do it?

>I tried
>        while (<*>) {print;}
>as a test example, and it doesn't seem to work either. (Also, a few other
>glob() tests...)

Now if you were using a 5.* perl I would recommend the File::Dosglob module
that I use - If you are using dos under windows (3.1*) then you can get
the djgpp version, infact you could get a version of bash and a whole load
of ports of gnu stuff.

Most archives will have this stuff or just search for "djgpp".

/J\



Mon, 10 Jul 2000 03:00:00 GMT  
 DOS: command line wildcards

[snip]

Quote:
> Most archives will have this stuff or just search for "djgpp".
> GNU for DOS is at:

ftp://ftp.cygnus.com/pub/gnu-win32/latest

--
Cheers,
Ron Savage




Tue, 11 Jul 2000 03:00:00 GMT  
 DOS: command line wildcards


: #     perl -n test.pl *.dat
: # but the wildcard does not seem to be expanded into all the matching
: # filenames! This is a fundamental feature of tools like grep and awk -

: It's not a feature of the tools.  It's the shell's feature, a real
: shells's, that is.
Hmm.. true of the (original) unix tools; but the DOS ports I have of
these tools do have this feature... I'm using 16 bit DOS 5.0, BTW

: # how do I get perl to do it?
: It's the shell that is supposed to expand the wildcard.  In DOS, if I
: recall correctly, the shell doesn't expand wildcards.  So you have to
: do it yourself.  

Sort of goes against the idea of Perl, doesn't it? Quoting from the
preface of Camel book:

        "Perl is different. In a nutshell, Perl is designed to make the
easy jobs easy, without making the hard jobs impossible."

OTOH, this was surely talking about the Unix version of Perl, which
does have access to a real shell.

--
Brendan Macmillan



Tue, 11 Jul 2000 03:00:00 GMT  
 DOS: command line wildcards



Quote:
>: # how do I get perl to do it?
>: It's the shell that is supposed to expand the wildcard.  In DOS, if I
>: recall correctly, the shell doesn't expand wildcards.  So you have to
>: do it yourself.  

> Sort of goes against the idea of Perl, doesn't it? Quoting from the
> preface of Camel book:

>    "Perl is different. In a nutshell, Perl is designed to make the
> easy jobs easy, without making the hard jobs impossible."


that unix type shells do globbing for you, and replace globs with an
actual list of files has nothing to do with perl. Perl is designed ot
make jobs easy, but perl was not designed to do everything for you.
Surely you don't suggest that perl should have all the internals of a
full OS in it, do you? I mean, there are things which can be done on
Unices, but not on DOS/Win32, e.g. symbolic links.

I want to create a FIFO(*) special file on my DOS box running DOS 1.12,
how can I do that with perl?

I want to use 18 GB of internal memory, but DOS won't allow it. How
can perl fix this?

You see, there are things that perl cannot fix. What your shell does
with a glob expression is something that is totally outside of perl's
control. I suggest you either get a shell that does it (and yes, there
are some), or use one of the perl builtin globbing functions, or one
of the globbing modules (there is one for DOS style, and one for ksh
style, I think.

Even perl has to succumb to the GIGO(**) rules.

Martien

(*) First In, First Out
(**) Garbage In, Garbage Out
--
Martien Verbruggen                  |
Webmaster www.tradingpost.com.au    | Advertising:  The science of arresting
Commercial Dynamics Pty. Ltd.       | the human intelligence long enough to
NSW, Australia                      | get money from it.



Tue, 11 Jul 2000 03:00:00 GMT  
 DOS: command line wildcards

: >  "Perl is different. In a nutshell, Perl is designed to make the
: > easy jobs easy, without making the hard jobs impossible."
:
: Perl is designed to make jobs easy, but perl was not designed to
: do everything for you.

Perl was designed to work with a shell that does these things for you?
The statement seems perfectly true in that context.

: I suggest you either get a shell that does it (and yes, there are some),
I've looked long and hard for unix-style shells for DOS; but I haven't
found a nice, small one yet - if you can reccommend one, I'd be happy
yo try it.

: or use one of the perl built-in globbing functions,
Perl 4.0 doesn't seem to have the glob fn:
        while (<*>) {print;}
does nothing.

: or one of the globbing modules (there is one for DOS style, and one for
: ksh style, I think.
These are for Perl 5.0, aren't they?

Perhaps my question should be: how can I expand the wildcards in perl?

If it has to be written in great detail, I'm probably really better
off staying with awk.

--
Brendan Macmillan



Tue, 11 Jul 2000 03:00:00 GMT  
 DOS: command line wildcards



Quote:

> Perl was designed to work with a shell that does these things for you?
> The statement seems perfectly true in that context.

No, perl was designed to work independently of the shell. perl doesn't
care about how your shell is implemented. In this discussion, perl
just expects a list of file names. Who creates that list, and in what
way, is irrelevant to perl.

Quote:
>: I suggest you either get a shell that does it (and yes, there are some),
> I've looked long and hard for unix-style shells for DOS; but I haven't
> found a nice, small one yet - if you can reccommend one, I'd be happy
> yo try it.

I don't frequent the DOS archives very often anymore, but about 5+
years ago, I was running a sh like clone on my DOS box. I don't
remember it's name or where I got it.. Probably garbo.uwasa.fi or
wuarchive..

Quote:
>: or use one of the perl built-in globbing functions,
> Perl 4.0 doesn't seem to have the glob fn:
>    while (<*>) {print;}
> does nothing.

>: or one of the globbing modules (there is one for DOS style, and one for
>: ksh style, I think.
> These are for Perl 5.0, aren't they?

yep.

Quote:
> Perhaps my question should be: how can I expand the wildcards in perl?

I don't know enough about perl4 for DOS. I haven't really used perl 4
for a long time. I don't even have the documentation around anymore.
Maybe you should search through the documentation for the word
glob? I seem to recall that the <*> notation did work in perl4,
but it does use an external shell to do the glob expansion (and
still does, I believe). It is possible that your perl4 just
doesn't have the right external shell around. Maybe someone with a
working knowledge of perl4 for DOS can answer this..

Martien

--
Martien Verbruggen                  | My friend has a baby. I'm writing down
Webmaster www.tradingpost.com.au    | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd.       | I can ask him what he meant - Steven
NSW, Australia                      | Wright



Sat, 15 Jul 2000 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Wildcards in DOS 'dir' command

2. how to implement files with wildcard in command line

3. Command line parameters / Wildcard characters / Recursive directories

4. tcgrep not expanding command-line wildcards

5. Filename Wildcard Command-line Interpolation

6. wildcards in command line

7. Perl command line processing, Windows/dos style ?

8. Using perl5 with Win95/dos command line.

9. Help: perl for DOS variable=something on command line

10. How do you connect to a dos command line script

11. Perl, DOS, and wildcards

12. using wildcards with unlink command

 

 
Powered by phpBB® Forum Software