in reply to Getting the output of a shell command

Here is how I would do it:

#!/usr/local/bin/perl -w ## ^^^^ change to your system needs. # for the best results in all your perl scripting # use strict. :) use strict; # edit these to match your needs. Remember # for dos, you will need to change the '/'s # to '\'s my $path = "/tmp"; my $file = "$ENV{HOME}/file.txt"; # open our descriptors. One for the directory # we need to read and one for the file in which # we will spool the directory information out to. opendir(DIR,$path) or die("Cannot open $path\n"); open(OP,">>$file") or die("Cannot open $file for writing\n"); # print out all files matching *.pl to file # descriptor OP (output) from reading the # DIR descriptor pointing back to $path. print OP join("\n",grep(/.*\.pl/,readdir(DIR))); # close our descriptors close(DIR); close(OP);
ADDED:
IMO, it is better to try and let the script do it all (unless you are writing a shell script (unix)or something similar) rather than calling system programs to do the work for you. It takes less machine resources to let the script (perl) do all the work for you.

For the above example, you may need to change the $path and $file variables to work for your windows machine but the rest *should* work just fine.

Edited by Snafu 1607 HRS EDT for completeness

----------
- Jim