perl 3.0 patch #22 patch #19, continued
[p5sagit/p5-mst-13.2.git] / msdos / README.msdos
CommitLineData
0f85fab0 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
7directory--law]
8
91. Compiling.
10
11 Perl has been compiled under MS-DOS using the Microsoft
12C compiler version 5.1. Before compiling install dir.h as
13<sys/dir.h>. You will need a Unix-like make program (e.g.
14pdmake) and something like yacc (e.g. bison). You could get
15away by running yacc and dry running make on a Unix host,
16but I haven't tried it. Compilation takes 12 minutes on a
1720MHz 386 machine (together with formating the manual), so
18you will probably need something to do in the meantime. The
19executable is 272k and the top level directory needs 1M for
20sources and about the same ammount for the object code and
21the executables.
22
23 The makefile will compile glob for you which you will
24need to place somewhere in your path so that perl globbing
25will work correctly. I have not tried all the tests or the
26examples, nor the awk and sed to Perl translators. You are
27on your own with them. In the eg directory I have included
28an example program that uses ioctl to display the charac-
29teristics of the storage devices of the system.
30
312. Using MS-DOS Perl
32
33 The MS-DOS version of perl has most of the functional-
34ity of the Unix version. Functions that can not be provided
35under MS-DOS like sockets, password and host database
36access, fork and wait have been ommited and will terminate
37with a fatal error. Care has been taken to implement the
38rest. In particular directory access, redirection (includ-
39ing pipes, but excluding the pipe function), system, ioctl
40and sleep have been provided.
41
87250799 42[Files currently can be edited in-place provided you are cre-
43ating a backup. However, if the backup coincidentally has
44the same name as the original, or if the resulting backup
45filename is invalid, then the file will probably be trashed.
46For example, don't do
47
48 perl -i~ script makefile
49 perl -i.bak script file.dat
50
51because (1) MS-DOS treats "makefile~" and "makefile" as the
52same filename, and (2) "file.dat.bak" is an invalid filename.
53The files "makefile" and "file.dat" will probably be lost
54forever. Moral of the story: Don't use in-place editing
55under MS-DOS. --rjc]
56
0f85fab0 572.1. Interface to the MS-DOS ioctl system call.
58
59 The function code of the ioctl function (the second
60argument) 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
67successful:
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-
74guish between the return value and the success of ioctl.
75
76 Some ioctl functions need a number as the first argu-
77ment. Provided that no other files have been opened the
78number can be obtained if ioctl is called with
79@fdnum[number] as the first argument after executing the
80following 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
892.2. Binary file access
90
91 Files are opened in text mode by default. This means
92that CR LF pairs are translated to LF. If binary access is
93needed the `binary' function should be used. There is
94currently no way to reverse the effect of the binary func-
95tion. If that is needed close and reopen the file.
96
972.3. Interpreter startup.
98
99 The effect of the Unix #!/bin/perl interpreter startup
100can be obtained under MS-DOS by giving the script a .bat
101extension 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
108front 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