perl 3.0 patch #22 patch #19, continued
[p5sagit/p5-mst-13.2.git] / msdos / README.msdos
1                    Notes on the MS-DOS Perl port
2
3                         Diomidis Spinellis
4                          (dds@cc.ic.ac.uk)
5
6 [0. First copy the files in the msdos directory into the parent
7 directory--law]
8
9 1.  Compiling.
10
11      Perl has been compiled under MS-DOS using the Microsoft
12 C  compiler  version 5.1.  Before compiling install dir.h as
13 <sys/dir.h>.  You will need a Unix-like make  program  (e.g.
14 pdmake) and something like yacc (e.g. bison).  You could get
15 away by running yacc and dry running make on  a  Unix  host,
16 but  I  haven't tried it.  Compilation takes 12 minutes on a
17 20MHz 386 machine (together with formating the  manual),  so
18 you  will probably need something to do in the meantime. The
19 executable is 272k and the top level directory needs 1M  for
20 sources  and  about the same ammount for the object code and
21 the executables.
22
23      The makefile will compile glob for you which  you  will
24 need  to  place somewhere in your path so that perl globbing
25 will work correctly.  I have not tried all the tests or  the
26 examples,  nor the awk and sed to Perl translators.  You are
27 on your own with them.  In the eg directory I have  included
28 an  example  program  that uses ioctl to display the charac-
29 teristics of the storage devices of the system.
30
31 2.  Using MS-DOS Perl
32
33      The MS-DOS version of perl has most of the  functional-
34 ity of the Unix version.  Functions that can not be provided
35 under  MS-DOS  like  sockets,  password  and  host  database
36 access,  fork  and wait have been ommited and will terminate
37 with a fatal error.  Care has been taken  to  implement  the
38 rest.   In particular directory access, redirection (includ-
39 ing pipes, but excluding the pipe function),  system,  ioctl
40 and sleep have been provided.
41
42 [Files currently can be edited in-place provided you are cre-
43 ating  a  backup.   However, if the backup coincidentally has 
44 the same name as the original, or  if  the  resulting  backup 
45 filename  is invalid, then the file will probably be trashed.
46 For example, don't do
47
48         perl -i~ script makefile
49         perl -i.bak script file.dat
50
51 because  (1)  MS-DOS treats "makefile~" and "makefile" as the
52 same filename, and (2) "file.dat.bak" is an invalid filename.
53 The  files  "makefile"  and  "file.dat" will probably be lost 
54 forever.  Moral of the story:   Don't  use  in-place  editing 
55 under MS-DOS. --rjc]
56
57 2.1.  Interface to the MS-DOS ioctl system call.
58
59      The function code of the  ioctl  function  (the  second
60 argument) is encoded as follows:
61
62 - The lowest nibble of the function code goes to AL.
63 - The two middle nibbles go to CL.
64 - The high nibble goes to CH.
65
66      The return code is -1 in the case of an  error  and  if
67 successful:
68
69 - for functions AL = 00, 09, 0a the value of the register DX
70 - for functions AL = 02 - 08, 0e the value of the register AX
71 - for functions AL = 01, 0b - 0f the number 0.
72
73      See the perl manual for instruction on how  to  distin-
74 guish between the return value and the success of ioctl.
75
76      Some ioctl functions need a number as the  first  argu-
77 ment.   Provided  that  no  other files have been opened the
78 number  can  be   obtained   if   ioctl   is   called   with
79 @fdnum[number]  as  the  first  argument after executing the
80 following code:
81
82         @fdnum = ("STDIN", "STDOUT", "STDERR");
83         $maxdrives = 15;
84         for ($i = 3; $i < $maxdrives; $i++) {
85                 open("FD$i", "nul");
86                 @fdnum[$i - 1] = "FD$i";
87         }
88
89 2.2.  Binary file access
90
91      Files are opened in text mode by default.   This  means
92 that  CR LF pairs are translated to LF.  If binary access is
93 needed the `binary'  function  should  be  used.   There  is
94 currently  no  way to reverse the effect of the binary func-
95 tion.  If that is needed close and reopen the file.
96
97 2.3.  Interpreter startup.
98
99      The effect of the Unix #!/bin/perl interpreter  startup
100 can  be  obtained  under  MS-DOS by giving the script a .bat
101 extension and using the following lines on its begining:
102
103         @REM=("
104         @perl %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
105         @end ") if 0 ;
106
107 (Note that you will probably want an absolute path name in
108 front of %0.bat).
109
110                                 March 1990
111
112                                 Diomidis Spinellis <dds@cc.ic.ac.uk>
113                                 Myrsinis 1
114                                 GR-145 62 Kifissia
115                                 Greece