1 Notes on the MS-DOS Perl port
6 [0. First copy the files in the msdos directory into the parent
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
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.
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.
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.
48 perl -i~ script makefile
49 perl -i.bak script file.dat
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
57 2.1. Interface to the MS-DOS ioctl system call.
59 The function code of the ioctl function (the second
60 argument) is encoded as follows:
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.
66 The return code is -1 in the case of an error and if
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.
73 See the perl manual for instruction on how to distin-
74 guish between the return value and the success of ioctl.
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
82 @fdnum = ("STDIN", "STDOUT", "STDERR");
84 for ($i = 3; $i < $maxdrives; $i++) {
86 @fdnum[$i - 1] = "FD$i";
89 2.2. Binary file access
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.
97 2.3. Interpreter startup.
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:
104 @perl %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
107 (Note that you will probably want an absolute path name in
112 Diomidis Spinellis <dds@cc.ic.ac.uk>
117 --------------------------------------------------------------------------
119 Revisions to the MS-DOS support in Perl 4.0
120 Tom Dinger, 18 March 1991
122 The DOS compatibility added to Perl sometime in release 3.x was not
123 maintained, and Perl as distributed could not be built without changes.
125 Both myself and Len Reed more or less "rediscovered" how to get Perl built
126 and running reliably for MS-DOS, using the Microsoft C compiler. He and I
127 have communicated, and will be putting together additional patches for the
132 For now, I have not supplied a makefile, as there is no standard for
133 make utilities under DOS. All the files can be compiled with Microsoft
134 C 5.1, using the switches "-AL -Ox" for Large memory model, maximum
135 optimization (this turned out a few code generation bugs in MSC 5.1).
136 The code will also compile with MSC 6.00A, with the optimization
137 "-Oacegils /Gs" for all files (regcomp.c has special case code to change
138 the aliasing optimizations).
140 Generally, you follow the instructions given above to compile and build
141 Perl 4.0 for DOS. I used the output of SunOS yacc run on perly.y,
142 without modification, but I expect both Bison and Berkeley-YACC will work
143 also. From inspection of the generated code, however, I believe AT&T
144 derived YACC produces the smallest tables, i.e. uses the least memory.
145 This is important for a 300K executable file.
149 You will need the file suffix.c from the os2 subdirectory -- it will
150 create a backup file with much less danger for DOS.
152 3. A "Smarter" chdir() function.
154 I have added to the DOS version of Perl 4.0 a replacement chdir()
155 function. Unlike the "normal" behavior, it is aware of drive letters
156 at the start of paths for DOS. So for example:
158 perl_chdir( "B:" ) changes to the default directory, on drive B:
159 perl_chdir( "C:\FOO" ) changes to the specified directory, on drive C:
160 perl_chdir( "\BAR" ) changes to the specified directory on the
163 4. *.BAT Scripts as Perl scripts
165 The strategy described above for turning a Perl script into a *.BAT
166 script do not work. I have been using the following lines at the
167 beginning of a Perl *.BAT script:
170 @perl -S %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
173 and the following at the end of the *.BAT script:
178 If you like, with the proper editor you can replace the four '!'
179 characters with some untypeable character, such as Ctrl-A. This will
180 allow you to pass any characters, including ".." strings as arguments.
184 * Better temporary file handling.
185 * A real Makefile -- Len Reed has one for Dmake 3.6
186 * Swapping code -- swaps most of Perl out of memory (to EMS, XMS or
187 disk) before running a sub-program or pipe.
188 * MKS command line support, both into Perl, and to other programs
190 * Smarter pipe functions, not using COMMAND.COM.