home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / perl / perlkit / readme.env < prev   
Text File  |  1990-11-15  |  10KB  |  237 lines

  1. Environment Usage in MS-DOS.
  2. ----------------
  3.  
  4. All pathnames can have forward or back slashes.  (This is also true
  5. of file names explicitly used in perl.  The system call handlers in
  6. MS-DOS like / fine; it's command.com and other programs that are picky.)
  7.  
  8. Environment variables are interpreted when they are needed.
  9. (Exception: creation of $TMP from $TMPDIR is done at startup.)  Thus the
  10. perl script can change them.  For example, if a huge "pipe" file is
  11. to be created, and there's room on the hard disk (c:) but not the
  12. usual $TMP, which is a RAM disk, one could write:
  13.  
  14.     ENV{'TMP'} = "c:/tmp";
  15.     open (HANDLE, "program|");
  16.  
  17. The state of the environment passed to perl.exe determines argument
  18. parsing, though, since this is done before compilation and interpretation
  19. of the perl script.
  20.  
  21. PATH        Semicolon-separated path list.  The current directory is
  22.         search first unless $MKSARGS is defined and MKS support is
  23.         compiled in, in which case the current directory is searched
  24.         only in response to an explicit "."or null path component.
  25.  
  26. MKSARGS     Set to 1 enable all MKSisms.  The MKS tools can assume that the
  27.         other pieces of the toolkit are lying around, but perl.exe
  28.         can't.  (It may be the only MKS-compatible program on a
  29.         system.)  If have have the MKS tools, you should set this
  30.         variable.  Perl will recoginize and generate MKS compatible
  31.         arguments in any case, but without the switch will default
  32.         SLASHC to "-c" instead of "-ce", will fail to run MKS
  33.         glob, and will run perl's glob instead of the Korn shell
  34.         to expand expressions like <*.c>.  Note that MKS support can
  35.         also be compiled out.
  36.  
  37. ROOTDIR        Full drive and path where MKS toolkit is installed.  Example,
  38.         "c:/mks" or "d:/".  Typically is already set in MKS environment.
  39.         Used only if $MKSARGS is set and $GLOB is not.  See GLOB.
  40.         Ignored if MKS support compiled out.
  41.  
  42. TMP        First choice for temporary files, e.g., "h:\\tmp".  If not set,
  43.         uses $TMPDIR (see below), if that's not set, the current directory
  44.         is used.  Swapping also goes here unless $EXESWAP is defined.
  45.         Temp files are pseudo-pipes, the swap file, and the -e file.
  46.  
  47. TMPDIR        If $TMPDIR is set and $TMP is not, the following is done internally:
  48.         ( $ENV{'TMP'} = $ENV{'TMPDIR'} ) =~ s,/,\\,g;
  49.         (Backslashes are reversed as a gesture to decendents of
  50.         the perl process.)  Creation of $ENV{'TMP'} from $TMPDIR is
  51.         done at perl.exe startup.  Note that the MKS tools use $TMPDIR as
  52.         a first choice; as a gesture of compatibility here, though,
  53.         here it is a second choice.
  54.  
  55. EXESWAP     First choice for swap out file location.  A RAM disk is
  56.         a nice choice.  $TMP is used if this isn't set.  (See also
  57.         $TMPDIR).  The swap file created the first time swapping is
  58.         invoked and is left open until perl exits or does an exec.
  59.         Set to ".off" (note illegal DOS name) to inhibit swapping--
  60.         useful for speedy running of small subprocesses.  This feature
  61.         (inhibition) can be turned on and off:
  62.         $ENV{'EXESWAP'} = 'e:/tmp';    # directory for swap file
  63.         system "ls";    # perl opens swap file and swaps to run ls
  64.         $ENV{'EXESWAP'} = '.off';    # temporarily disable swap
  65.         system "who";    # no swapping, who run in available memory
  66.         $ENV{'EXESWAP'} = 'yes';    # anything other that '.off'.
  67.         system "ps";    # swapping to original file
  68.  
  69. GLOB        First choice for MKS globbing program: full path, name,
  70.         and extension.  Example: "d:/mks/etc/glob.exe".  The perl
  71.         globbing program (used for <*.c> expansion) is found, as
  72.         before, via the $PATH.  Used only in an MKS environment, and
  73.         then only when perl is run from a non-MKS program.  Ignored
  74.         if MKS support compiled out.
  75.  
  76. SHELL        Full path name and extension of the shell used used for
  77.         subprocesses when wildcard expansion is required, e.g.,
  78.         "c:/mks/bin/sh.exe".  If undefined, COMSPEC is used.
  79.         Presumably this could be the MKS korn shell, but it can
  80.         be another shell (e.g., 4DOS) and thus $SHELL is inspected
  81.         even if MKS support is compiled out.
  82.  
  83. COMPSEC        Full path name of DOS command interpreter, e.g., "c:\\command.com"
  84.         Used only if $SHELL is not defined.  If not found, "\\command.com"
  85.         is used.  (It is bad practice to allow $COMSPEC to default or to
  86.         have it have anything other than a full drive and path name.  You
  87.         don't want your programs looking for command.com on alternate
  88.         drives.)
  89.  
  90. METACHAR    List of characters that are metacharacters to the $SHELL or
  91.         $COMPSPEC.  Used to determine if command can be run directly or
  92.         if a subshell must be invoked.  If undefined, |<> is used
  93.         for COMSPEC and *"?<>|()&][$#`'\ for SHELL.
  94.  
  95. SLASHC        The shell option for invoking a command.  Defaults:
  96.         /c for $COMSPEC, DOS version 4.x or better [sic]
  97.         sc where s is the switch character, for $COMSPEC, DOS < 4.0
  98.         -ce for $SHELL if $MKSARGS is set and MKS support is compiled in.
  99.         (-e needed to get status back).  -c for other $SHELLs.
  100.         (This is a guess.)
  101.  
  102. PERLLIB        Directory containing perl library.  Defaults to
  103.         /usr/local/lib/perl.  Should be applicable even in Unix.
  104.  
  105. Globbing Conventions
  106. ------------------------------------
  107.  
  108. Unix and MKS do globbing differently than MS-DOS.  Under Unix and MKS,
  109. "abc*" matches abc.c,  Under DOS, though, the * won't match '.'
  110. The MKS tools use the former interpretation; the glob program distributed
  111. with perl and the globbing built in to perl.exe use the latter.  (Don't
  112. install the distributed glob.exe if you are using the MKS tools.)
  113.  
  114. You can also write your own globber and call it ___setargv (__setargv in C)
  115. to replace the Microsoft library stuff.
  116.  
  117. Interpretation of Incoming Arguments
  118. ------------------------------------
  119.  
  120. There are three cases:
  121.     1) Perl.exe was invoked MKS-style.  The arguments are pulled from the
  122.        environment as per MKS dodsexec(5).  Several kilobytes of pre-globbed
  123.        arguments can be passed this way.  Works even if $MKSARGS is not set,
  124.        but not if MKS support is compiled out.
  125.  
  126.     2) Perl.exe was was invoked in non-MKS style but the MKS tools are intact.
  127.        This will happen if there's if perl.exe is run by an incompatible
  128.        program, such as Microsoft NMAKE, even though the toolkit is intact.
  129.        The toolkit is presumed present iff $MKSARGS is set.  The MKS glob
  130.        program is looked for in $GLOB, $ROOTDIR/etc/glob.exe, and
  131.        /etc/glob.exe in that order.  (User really should set $ROOTDIR or
  132.        $GLOB to avoid problems with "which drive?")  This step is not
  133.        done if MKS support is compiled out.
  134.  
  135.     3) Perl.exe was invoked and $MKSARGS was not set or MKS support was
  136.        compiled out.  Perl globs the arguments itself, using the
  137.        ___setargv code in the Microsoft library.  That code deals with
  138.        double (but not single) quotes and expands wildcards in the
  139.        usual DOS manner, i.e., as in DIR and COPY.
  140.  
  141. Globbing <wildcards> Expressions
  142. ------------------------------------
  143.  
  144. Expressions like <*.c> are expanded by a subshell in Unix.  Under DOS,
  145. there are the following cases:
  146.  
  147. 1) $MKSARGS is defined and MKS support is compiled in.  The $SHELL is used,
  148.    running echo piped to tr exactly as with the Bourne shell on Unix perl.
  149.  
  150. 2) The supplied glob.exe is run.  This program simply takes the supplied
  151.    command line, DOS-globs it, and writes the result, "\r\n" separated,
  152.    to the perl process via a "pipe."
  153.  
  154. Running Subprocesses
  155. ------------------------------------
  156.  
  157. Perl.exe will by default swap itself out almost entirely when it runs a
  158. subprocess other than MKS $GLOB.  (See EXESWAP).  The swap file is
  159. opened when the first subprocess is run and is left open until perl
  160. exits or does an exec.
  161.  
  162. The command line to be run is scanned for $METACHARacters as described
  163. above.  If none are found, the subcommand is invoked directly.  If
  164. metacharacter(s) are found, a $SHELL or $COMSPEC is invoked to run the command.
  165.  
  166. Use of a single | in a open() command does not constitute a metacharcter:
  167. this is a directive to perl to open a pipe.  The following, too, has
  168. no SHELL metacharacters since the subprocess is simply pwd:
  169.     chop($direct = `pwd`);
  170.  
  171. Beware of MS-DOS "internal" commands; i.e., those that are built into
  172. command.com.  Examples are DIR and COPY.  COMMAND.COM users can use
  173. these directly if the command has $METACHARacters; if not, you must
  174. invoke an explicit command.com:
  175.  
  176.     system "dir >my.fil";           # > is a metacharacter
  177.     system "$ENV{'COMSPEC'} /c ver";   # no metacharacters, must be explicit
  178.  
  179. Users of other $SHELLs must use the second format for anything to be
  180. passed to command.com.
  181.  
  182. Be aware that no wild card expansion is going to be done by command.com
  183. usless you're using one of the built-in commands that does it (e.g., COPY).
  184. You can use <> expansion to get around this.  Even those who have fancy
  185. $SHELLs should take note of this, since having perl run the $SHELL and
  186. then the command uses less memory than if perl runs the $SHELL which runs
  187. the command.
  188.  
  189.     $files = <*.c>;
  190.     `the_com $files`;
  191. intead of
  192.     `the_com *.c`;
  193.  
  194. Typical MKS setup in profile.ksh
  195. ------------------------------------
  196.  
  197. # If you're using the MKS stuff, you probably don't have to do anything
  198. # other than set MKSARGS.
  199.  
  200. export MKSARGS=1
  201. # ROOTDIR set by init process or etc.rc or here.
  202. export TMPDIR=e:/tmp
  203. # EXESWAP left to default to $TMPDIR
  204. # GLOB left to default to $ROOTDIR/etc/glob.exe
  205. # SHELL set by init process or here.
  206. # COMSPEC not used by perl.exe but probably defined for other uses.
  207. # METACHAR not defined, left to default.
  208. export PERLLIB=c:/lib/perl
  209.  
  210. Typical command.com setup in autoexec.bat
  211. ------------------------------------
  212.  
  213. Rem You probably don't need to do anything except set $TMP, which you
  214. Rem may be doing anyway.
  215.  
  216. Rem MKSARGS not set
  217. Rem ROOTDIR not used
  218. set TMP=d:\tmp
  219. Rem EXESWAP left to default to $TMP
  220. Rem GLOB not used
  221. Rem SHELL not set
  222. Rem COMPEC set by config.sys SHELL command or by MS-DOS startup.
  223. Rem METACHAR not defined, left to default.
  224. set PERLLIB=c:/lib/perl
  225.  
  226. Typical setup in autoexec.bat for user of some other shell
  227. ------------------------------------
  228. Rem MKSARGS not set
  229. Rem ROOTDIR not used
  230. set TMP=d:\tmp
  231. Rem EXESWAP left to default to $TMP
  232. Rem GLOB not used
  233. set SHELL=c:\bin\whatever.exe
  234. Rem COMPEC set by config.sys SHELL command or by MS-DOS startup.
  235. set METACHAR=?*<>|    # or whatever, shell dependent
  236. set PERLLIB=c:/lib/perl
  237.