Commit | Line | Data |
---|---|---|
e41182b5 GS |
1 | =head1 NAME |
2 | ||
3 | perlport - Writing portable Perl | |
4 | ||
5 | ||
6 | =head1 DESCRIPTION | |
7 | ||
8 | Perl runs on a variety of operating systems. While most of them share | |
9 | a lot in common, they also have their own very particular and unique | |
10 | features. | |
11 | ||
12 | This document is meant to help you to find out what constitutes portable | |
0a47030a | 13 | Perl code, so that once you have made your decision to write portably, |
e41182b5 GS |
14 | you know where the lines are drawn, and you can stay within them. |
15 | ||
6ab3f9cb GS |
16 | There is a tradeoff between taking full advantage of one particular type |
17 | of computer, and taking advantage of a full range of them. Naturally, | |
0a47030a GS |
18 | as you make your range bigger (and thus more diverse), the common |
19 | denominators drop, and you are left with fewer areas of common ground in | |
20 | which you can operate to accomplish a particular task. Thus, when you | |
21 | begin attacking a problem, it is important to consider which part of the | |
22 | tradeoff curve you want to operate under. Specifically, whether it is | |
23 | important to you that the task that you are coding needs the full | |
24 | generality of being portable, or if it is sufficient to just get the job | |
25 | done. This is the hardest choice to be made. The rest is easy, because | |
26 | Perl provides lots of choices, whichever way you want to approach your | |
27 | problem. | |
28 | ||
29 | Looking at it another way, writing portable code is usually about | |
30 | willfully limiting your available choices. Naturally, it takes discipline | |
31 | to do that. | |
e41182b5 GS |
32 | |
33 | Be aware of two important points: | |
34 | ||
6ab3f9cb | 35 | |
e41182b5 GS |
36 | =over 4 |
37 | ||
38 | =item Not all Perl programs have to be portable | |
39 | ||
40 | There is no reason why you should not use Perl as a language to glue Unix | |
41 | tools together, or to prototype a Macintosh application, or to manage the | |
42 | Windows registry. If it makes no sense to aim for portability for one | |
43 | reason or another in a given program, then don't bother. | |
44 | ||
6ab3f9cb | 45 | =item The vast majority of Perl I<is> portable |
e41182b5 GS |
46 | |
47 | Don't be fooled into thinking that it is hard to create portable Perl | |
48 | code. It isn't. Perl tries its level-best to bridge the gaps between | |
49 | what's available on different platforms, and all the means available to | |
50 | use those features. Thus almost all Perl code runs on any machine | |
6ab3f9cb | 51 | without modification. But there are some significant issues in |
e41182b5 GS |
52 | writing portable code, and this document is entirely about those issues. |
53 | ||
54 | =back | |
55 | ||
6ab3f9cb | 56 | |
e41182b5 GS |
57 | Here's the general rule: When you approach a task that is commonly done |
58 | using a whole range of platforms, think in terms of writing portable | |
59 | code. That way, you don't sacrifice much by way of the implementation | |
60 | choices you can avail yourself of, and at the same time you can give | |
61 | your users lots of platform choices. On the other hand, when you have to | |
62 | take advantage of some unique feature of a particular platform, as is | |
63 | often the case with systems programming (whether for Unix, Windows, | |
64 | S<Mac OS>, VMS, etc.), consider writing platform-specific code. | |
65 | ||
0a47030a GS |
66 | When the code will run on only two or three operating systems, then you |
67 | may only need to consider the differences of those particular systems. | |
68 | The important thing is to decide where the code will run, and to be | |
69 | deliberate in your decision. | |
70 | ||
71 | The material below is separated into three main sections: main issues of | |
72 | portability (L<"ISSUES">, platform-specific issues (L<"PLATFORMS">, and | |
73 | builtin perl functions that behave differently on various ports | |
74 | (L<"FUNCTION IMPLEMENTATIONS">. | |
e41182b5 GS |
75 | |
76 | This information should not be considered complete; it includes possibly | |
b8099c3d | 77 | transient information about idiosyncrasies of some of the ports, almost |
e41182b5 GS |
78 | all of which are in a state of constant evolution. Thus this material |
79 | should be considered a perpetual work in progress | |
80 | (E<lt>IMG SRC="yellow_sign.gif" ALT="Under Construction"E<gt>). | |
81 | ||
82 | ||
83 | =head1 ISSUES | |
84 | ||
85 | =head2 Newlines | |
86 | ||
638bc118 | 87 | In most operating systems, lines in files are terminated by newlines. |
e41182b5 GS |
88 | Just what is used as a newline may vary from OS to OS. Unix |
89 | traditionally uses C<\012>, one kind of Windows I/O uses C<\015\012>, | |
90 | and S<Mac OS> uses C<\015>. | |
91 | ||
92 | Perl uses C<\n> to represent the "logical" newline, where what | |
93 | is logical may depend on the platform in use. In MacPerl, C<\n> | |
94 | always means C<\015>. In DOSish perls, C<\n> usually means C<\012>, but | |
95 | when accessing a file in "text" mode, STDIO translates it to (or from) | |
6ab3f9cb | 96 | C<\015\012>. C<\015\012> is commonly referred to as CRLF. |
e41182b5 GS |
97 | |
98 | Due to the "text" mode translation, DOSish perls have limitations | |
99 | of using C<seek> and C<tell> when a file is being accessed in "text" | |
100 | mode. Specifically, if you stick to C<seek>-ing to locations you got | |
101 | from C<tell> (and no others), you are usually free to use C<seek> and | |
102 | C<tell> even in "text" mode. In general, using C<seek> or C<tell> or | |
103 | other file operations that count bytes instead of characters, without | |
104 | considering the length of C<\n>, may be non-portable. If you use | |
105 | C<binmode> on a file, however, you can usually use C<seek> and C<tell> | |
106 | with arbitrary values quite safely. | |
107 | ||
108 | A common misconception in socket programming is that C<\n> eq C<\012> | |
0a47030a | 109 | everywhere. When using protocols such as common Internet protocols, |
e41182b5 GS |
110 | C<\012> and C<\015> are called for specifically, and the values of |
111 | the logical C<\n> and C<\r> (carriage return) are not reliable. | |
112 | ||
113 | print SOCKET "Hi there, client!\r\n"; # WRONG | |
114 | print SOCKET "Hi there, client!\015\012"; # RIGHT | |
115 | ||
0a47030a GS |
116 | However, using C<\015\012> (or C<\cM\cJ>, or C<\x0D\x0A>) can be tedious |
117 | and unsightly, as well as confusing to those maintaining the code. As | |
6ab3f9cb | 118 | such, the Socket module supplies the Right Thing for those who want it. |
e41182b5 GS |
119 | |
120 | use Socket qw(:DEFAULT :crlf); | |
121 | print SOCKET "Hi there, client!$CRLF" # RIGHT | |
122 | ||
6ab3f9cb GS |
123 | When reading from a socket, remember that the default input record |
124 | separator C<$/> is C<\n>, but code like this should recognize C<$/> as | |
e41182b5 GS |
125 | C<\012> or C<\015\012>: |
126 | ||
127 | while (<SOCKET>) { | |
128 | # ... | |
129 | } | |
130 | ||
6ab3f9cb GS |
131 | Since both CRLF and LF end in LF, the input record separator can |
132 | be set to LF, and the CR can be stripped later, if present. Better: | |
e41182b5 GS |
133 | |
134 | use Socket qw(:DEFAULT :crlf); | |
135 | local($/) = LF; # not needed if $/ is already \012 | |
136 | ||
137 | while (<SOCKET>) { | |
138 | s/$CR?$LF/\n/; # not sure if socket uses LF or CRLF, OK | |
139 | # s/\015?\012/\n/; # same thing | |
140 | } | |
141 | ||
142 | And this example is actually better than the previous one even for Unix | |
143 | platforms, because now any C<\015>'s (C<\cM>'s) are stripped out | |
144 | (and there was much rejoicing). | |
145 | ||
6ab3f9cb GS |
146 | Similarly, functions that return text data--such as a function that |
147 | fetches a web page--should, in some cases, translate newlines before | |
148 | returning the data, if they've not yet been trsnalted to the local | |
149 | newline. Often one line of code will suffice: | |
2ee0eb3c CN |
150 | |
151 | $data =~ s/\015?\012/\n/g; | |
152 | return $data; | |
153 | ||
6ab3f9cb GS |
154 | Some of this may be confusing. Here's a handy reference to the ASCII CR |
155 | and LF characters. You can print it out and stick it in your wallet. | |
156 | ||
157 | LF == \012 == \x0A == \cJ == ASCII 10 | |
158 | CR == \015 == \x0D == \cM == ASCII 13 | |
159 | ||
160 | | Unix | DOS | Mac | | |
161 | --------------------------- | |
162 | \n | LF | LF | CR | | |
163 | \r | CR | CR | LF | | |
164 | \n * | LF | CRLF | CR | | |
165 | \r * | CR | CR | LF | | |
166 | --------------------------- | |
167 | * text-mode STDIO | |
168 | ||
169 | These are just the most common definitions of C<\n> and C<\r> in Perl. | |
170 | There may well be others. | |
171 | ||
e41182b5 | 172 | |
322422de GS |
173 | =head2 Numbers endianness and Width |
174 | ||
175 | Different CPUs store integers and floating point numbers in different | |
176 | orders (called I<endianness>) and widths (32-bit and 64-bit being the | |
177 | most common). This affects your programs if they attempt to transfer | |
6ab3f9cb GS |
178 | numbers in binary format from one CPU architecture to another over some |
179 | channel, usually either "live" via network connection, or by storing the | |
180 | numbers to secondary storage such as a disk file. | |
322422de GS |
181 | |
182 | Conflicting storage orders make utter mess out of the numbers: if a | |
183 | little-endian host (Intel, Alpha) stores 0x12345678 (305419896 in | |
184 | decimal), a big-endian host (Motorola, MIPS, Sparc, PA) reads it as | |
185 | 0x78563412 (2018915346 in decimal). To avoid this problem in network | |
6ab3f9cb GS |
186 | (socket) connections use the C<pack> and C<unpack> formats C<n> |
187 | and C<N>, the "network" orders. They are guaranteed to be portable. | |
322422de GS |
188 | |
189 | Different widths can cause truncation even between platforms of equal | |
190 | endianness: the platform of shorter width loses the upper parts of the | |
191 | number. There is no good solution for this problem except to avoid | |
192 | transferring or storing raw binary numbers. | |
193 | ||
194 | One can circumnavigate both these problems in two ways: either | |
195 | transfer and store numbers always in text format, instead of raw | |
6ab3f9cb GS |
196 | binary, or consider using modules like Data::Dumper (included in |
197 | the standard distribution as of Perl 5.005) and Storable. | |
198 | ||
19799a22 GS |
199 | Also, don't depend on specific values returned from C<printf> and |
200 | C<sprintf>. These in some cases may differ from platform to platform. | |
322422de | 201 | |
433acd8a | 202 | =head2 Files and Filesystems |
e41182b5 GS |
203 | |
204 | Most platforms these days structure files in a hierarchical fashion. | |
205 | So, it is reasonably safe to assume that any platform supports the | |
6ab3f9cb GS |
206 | notion of a "path" to uniquely identify a file on the system. How |
207 | that path is actually written differs. | |
e41182b5 GS |
208 | |
209 | While they are similar, file path specifications differ between Unix, | |
495c5fdc PG |
210 | Windows, S<Mac OS>, OS/2, VMS, VOS, S<RISC OS> and probably others. |
211 | Unix, for example, is one of the few OSes that has the idea of a single | |
212 | root directory. | |
322422de | 213 | |
6ab3f9cb GS |
214 | DOS, OS/2, VMS, VOS, and Windows can work similarly to Unix with C</> |
215 | as path separator, or in their own idiosyncratic ways (such as having | |
216 | several root directories and various "unrooted" device files such NIL: | |
217 | and LPT:). | |
322422de GS |
218 | |
219 | S<Mac OS> uses C<:> as a path separator instead of C</>. | |
220 | ||
6ab3f9cb GS |
221 | The filesystem may support neither hard links (C<link>) nor |
222 | symbolic links (C<symlink>, C<readlink>, C<lstat>). | |
433acd8a | 223 | |
6ab3f9cb | 224 | The filesystem may support neither access timestamp nor change |
433acd8a JH |
225 | timestamp (meaning that about the only portable timestamp is the |
226 | modification timestamp), or one second granularity of any timestamps | |
227 | (e.g. the FAT filesystem limits the time granularity to two seconds). | |
228 | ||
495c5fdc PG |
229 | VOS perl can emulate Unix filenames with C</> as path separator. The |
230 | native pathname characters greater-than, less-than, number-sign, and | |
231 | percent-sign are always accepted. | |
232 | ||
6ab3f9cb | 233 | S<RISC OS> perl can emulate Unix filenames with C</> as path |
322422de | 234 | separator, or go native and use C<.> for path separator and C<:> to |
6ab3f9cb | 235 | signal filesystems and disk names. |
e41182b5 | 236 | |
6ab3f9cb GS |
237 | If all this is intimidating, have no (well, maybe only a little) fear. |
238 | There are modules that can help. The File::Spec modules provide | |
239 | methods to do the Right Thing on whatever | |
e41182b5 GS |
240 | platform happens to be running the program. |
241 | ||
6ab3f9cb GS |
242 | use File::Spec::Functions; |
243 | chdir(updir()); # go up one directory | |
244 | $file = catfile(curdir(), 'temp', 'file.txt'); | |
e41182b5 GS |
245 | # on Unix and Win32, './temp/file.txt' |
246 | # on Mac OS, ':temp:file.txt' | |
247 | ||
248 | File::Spec is available in the standard distribution, as of version | |
249 | 5.004_05. | |
250 | ||
251 | In general, production code should not have file paths hardcoded; making | |
252 | them user supplied or from a configuration file is better, keeping in mind | |
253 | that file path syntax varies on different machines. | |
254 | ||
255 | This is especially noticeable in scripts like Makefiles and test suites, | |
256 | which often assume C</> as a path separator for subdirectories. | |
257 | ||
6ab3f9cb | 258 | Also of use is File::Basename, from the standard distribution, which |
e41182b5 GS |
259 | splits a pathname into pieces (base filename, full path to directory, |
260 | and file suffix). | |
261 | ||
19799a22 | 262 | Even when on a single platform (if you can call Unix a single platform), |
3c075c7d CN |
263 | remember not to count on the existence or the contents of |
264 | system-specific files or directories, like F</etc/passwd>, | |
265 | F</etc/sendmail.conf>, F</etc/resolv.conf>, or even F</tmp/>. For | |
266 | example, F</etc/passwd> may exist but it may not contain the encrypted | |
6ab3f9cb | 267 | passwords because the system is using some form of enhanced security, |
3c075c7d CN |
268 | or it may not contain all the accounts because the system is using NIS. |
269 | If code does need to rely on such a file, include a description of the | |
270 | file and its format in the code's documentation, and make it easy for | |
271 | the user to override the default location of the file. | |
272 | ||
273 | Don't assume a text file will end with a newline. | |
e41182b5 | 274 | |
dd9f0070 | 275 | Do not have two files of the same name with different case, like |
3c075c7d | 276 | F<test.pl> and F<Test.pl>, as many platforms have case-insensitive |
dd9f0070 | 277 | filenames. Also, try not to have non-word characters (except for C<.>) |
0a47030a GS |
278 | in the names, and keep them to the 8.3 convention, for maximum |
279 | portability. | |
dd9f0070 | 280 | |
6ab3f9cb | 281 | Likewise, if using the AutoSplit module, try to keep the split functions to |
dd9f0070 CN |
282 | 8.3 naming and case-insensitive conventions; or, at the very least, |
283 | make it so the resulting files have a unique (case-insensitively) | |
284 | first 8 characters. | |
285 | ||
6ab3f9cb GS |
286 | There certainly can be whitespace in filenames on most systems, but |
287 | some may not allow it. Many systems (DOS, VMS) cannot have more than | |
288 | one C<.> in their filenames. | |
433acd8a JH |
289 | |
290 | Don't assume C<E<gt>> won't be the first character of a filename. | |
291 | Always use C<E<lt>> explicitly to open a file for reading. | |
0a47030a | 292 | |
6ab3f9cb | 293 | open(FILE, "< $existing_file") or die $!; |
0a47030a | 294 | |
6ab3f9cb GS |
295 | If filenames might use strange characters, it is safest to open it |
296 | with C<sysopen> instead of C<open>. C<open> is magic and can | |
297 | translate characters like C<E<gt>>, C<E<lt>>, and C<|>, which may | |
298 | be the wrong thing to do. | |
3c075c7d | 299 | |
e41182b5 GS |
300 | |
301 | =head2 System Interaction | |
302 | ||
303 | Not all platforms provide for the notion of a command line, necessarily. | |
304 | These are usually platforms that rely on a Graphical User Interface (GUI) | |
305 | for user interaction. So a program requiring command lines might not work | |
306 | everywhere. But this is probably for the user of the program to deal | |
6ab3f9cb | 307 | with, so don't stay up late worrying about it. |
e41182b5 GS |
308 | |
309 | Some platforms can't delete or rename files that are being held open by | |
310 | the system. Remember to C<close> files when you are done with them. | |
6ab3f9cb GS |
311 | Don't C<unlink> or C<rename> an open file. Don't C<tie> or C<open> a |
312 | file that is already tied or opened; C<untie> or C<close> first. | |
e41182b5 | 313 | |
0a47030a GS |
314 | Don't open the same file more than once at a time for writing, as some |
315 | operating systems put mandatory locks on such files. | |
316 | ||
e41182b5 | 317 | Don't count on a specific environment variable existing in C<%ENV>. |
0a47030a | 318 | Don't count on C<%ENV> entries being case-sensitive, or even |
e41182b5 GS |
319 | case-preserving. |
320 | ||
6ab3f9cb | 321 | Don't count on signals for anything. |
e41182b5 GS |
322 | |
323 | Don't count on filename globbing. Use C<opendir>, C<readdir>, and | |
324 | C<closedir> instead. | |
325 | ||
b8099c3d | 326 | Don't count on per-program environment variables, or per-program current |
dd9f0070 | 327 | directories. |
b8099c3d | 328 | |
3c075c7d CN |
329 | Don't count on specific values of C<$!>. |
330 | ||
e41182b5 GS |
331 | |
332 | =head2 Interprocess Communication (IPC) | |
333 | ||
334 | In general, don't directly access the system in code that is meant to be | |
0a47030a GS |
335 | portable. That means, no C<system>, C<exec>, C<fork>, C<pipe>, C<``>, |
336 | C<qx//>, C<open> with a C<|>, nor any of the other things that makes being | |
e41182b5 GS |
337 | a Unix perl hacker worth being. |
338 | ||
339 | Commands that launch external processes are generally supported on | |
340 | most platforms (though many of them do not support any type of forking), | |
341 | but the problem with using them arises from what you invoke with them. | |
342 | External tools are often named differently on different platforms, often | |
343 | not available in the same location, often accept different arguments, | |
344 | often behave differently, and often represent their results in a | |
345 | platform-dependent way. Thus you should seldom depend on them to produce | |
346 | consistent results. | |
347 | ||
348 | One especially common bit of Perl code is opening a pipe to sendmail: | |
349 | ||
19799a22 | 350 | open(MAIL, '|/usr/lib/sendmail -t') or die $!; |
e41182b5 GS |
351 | |
352 | This is fine for systems programming when sendmail is known to be | |
353 | available. But it is not fine for many non-Unix systems, and even | |
354 | some Unix systems that may not have sendmail installed. If a portable | |
19799a22 GS |
355 | solution is needed, see the C<Mail::Send> and C<Mail::Mailer> modules |
356 | in the C<MailTools> distribution. C<Mail::Mailer> provides several | |
357 | mailing methods, including mail, sendmail, and direct SMTP | |
358 | (via C<Net::SMTP>) if a mail transfer agent is not available. | |
e41182b5 GS |
359 | |
360 | The rule of thumb for portable code is: Do it all in portable Perl, or | |
0a47030a GS |
361 | use a module (that may internally implement it with platform-specific |
362 | code, but expose a common interface). | |
e41182b5 | 363 | |
19799a22 GS |
364 | The Unix System V IPC (C<msg*(), sem*(), shm*()>) is not available |
365 | even in all Unix platforms. | |
366 | ||
3c075c7d | 367 | |
e41182b5 GS |
368 | =head2 External Subroutines (XS) |
369 | ||
370 | XS code, in general, can be made to work with any platform; but dependent | |
371 | libraries, header files, etc., might not be readily available or | |
372 | portable, or the XS code itself might be platform-specific, just as Perl | |
373 | code might be. If the libraries and headers are portable, then it is | |
374 | normally reasonable to make sure the XS code is portable, too. | |
375 | ||
376 | There is a different kind of portability issue with writing XS | |
0a47030a GS |
377 | code: availability of a C compiler on the end-user's system. C brings |
378 | with it its own portability issues, and writing XS code will expose you to | |
e41182b5 GS |
379 | some of those. Writing purely in perl is a comparatively easier way to |
380 | achieve portability. | |
381 | ||
382 | ||
383 | =head2 Standard Modules | |
384 | ||
385 | In general, the standard modules work across platforms. Notable | |
6ab3f9cb | 386 | exceptions are the CPAN module (which currently makes connections to external |
e41182b5 | 387 | programs that may not be available), platform-specific modules (like |
6ab3f9cb | 388 | ExtUtils::MM_VMS), and DBM modules. |
e41182b5 GS |
389 | |
390 | There is no one DBM module that is available on all platforms. | |
6ab3f9cb GS |
391 | SDBM_File and the others are generally available on all Unix and DOSish |
392 | ports, but not in MacPerl, where only NBDM_File and DB_File are | |
0a47030a | 393 | available. |
e41182b5 GS |
394 | |
395 | The good news is that at least some DBM module should be available, and | |
6ab3f9cb | 396 | AnyDBM_File will use whichever module it can find. Of course, then |
e41182b5 | 397 | the code needs to be fairly strict, dropping to the lowest common |
6ab3f9cb GS |
398 | denominator (e.g., not exceeding 1K for each record), so that it will |
399 | work with any DBM module. See L<AnyDBM_File> for more details. | |
e41182b5 GS |
400 | |
401 | ||
402 | =head2 Time and Date | |
403 | ||
0a47030a GS |
404 | The system's notion of time of day and calendar date is controlled in |
405 | widely different ways. Don't assume the timezone is stored in C<$ENV{TZ}>, | |
406 | and even if it is, don't assume that you can control the timezone through | |
407 | that variable. | |
e41182b5 | 408 | |
322422de | 409 | Don't assume that the epoch starts at 00:00:00, January 1, 1970, |
6ab3f9cb GS |
410 | because that is OS- and implementation-specific. It is better to store a date |
411 | in an unambiguous representation. The ISO-8601 standard defines | |
412 | "YYYY-MM-DD" as the date format. A text representation (like "1987-12-18") | |
413 | can be easily converted into an OS-specific value using a module like | |
414 | Date::Parse. An array of values, such as those returned by | |
322422de | 415 | C<localtime>, can be converted to an OS-specific representation using |
6ab3f9cb | 416 | Time::Local. |
322422de | 417 | |
19799a22 GS |
418 | When calculating specific times, such as for tests in time or date modules, |
419 | it may be appropriate to calculate an offset for the epoch. | |
420 | require Time::Local; | |
421 | $offset = Time::Local::timegm(0, 0, 0, 1, 0, 70); | |
422 | The value for C<$offset> in Unix will be C<0>, but in Mac OS will be | |
423 | some large number. C<$offset> can then be added to a Unix time value | |
424 | to get what should be the proper value on any system. | |
322422de GS |
425 | |
426 | =head2 Character sets and character encoding | |
427 | ||
428 | Assume very little about character sets. Do not assume anything about | |
6ab3f9cb | 429 | the numerical values (C<ord>, C<chr>) of characters. Do not |
322422de | 430 | assume that the alphabetic characters are encoded contiguously (in |
3c075c7d | 431 | numerical sense). Do not assume anything about the ordering of the |
322422de GS |
432 | characters. The lowercase letters may come before or after the |
433 | uppercase letters, the lowercase and uppercase may be interlaced so | |
b1ff3570 | 434 | that both 'a' and 'A' come before the 'b', the accented and other |
322422de GS |
435 | international characters may be interlaced so that E<auml> comes |
436 | before the 'b'. | |
437 | ||
438 | ||
439 | =head2 Internationalisation | |
440 | ||
3c075c7d | 441 | If you may assume POSIX (a rather large assumption, that in practice |
19799a22 | 442 | means Unix), you may read more about the POSIX locale system from |
322422de | 443 | L<perllocale>. The locale system at least attempts to make things a |
3c075c7d | 444 | little bit more portable, or at least more convenient and |
322422de GS |
445 | native-friendly for non-English users. The system affects character |
446 | sets and encoding, and date and time formatting, among other things. | |
e41182b5 GS |
447 | |
448 | ||
449 | =head2 System Resources | |
450 | ||
0a47030a GS |
451 | If your code is destined for systems with severely constrained (or |
452 | missing!) virtual memory systems then you want to be I<especially> mindful | |
453 | of avoiding wasteful constructs such as: | |
e41182b5 GS |
454 | |
455 | # NOTE: this is no longer "bad" in perl5.005 | |
456 | for (0..10000000) {} # bad | |
457 | for (my $x = 0; $x <= 10000000; ++$x) {} # good | |
458 | ||
459 | @lines = <VERY_LARGE_FILE>; # bad | |
460 | ||
461 | while (<FILE>) {$file .= $_} # sometimes bad | |
0a47030a | 462 | $file = join('', <FILE>); # better |
e41182b5 GS |
463 | |
464 | The last two may appear unintuitive to most people. The first of those | |
465 | two constructs repeatedly grows a string, while the second allocates a | |
466 | large chunk of memory in one go. On some systems, the latter is more | |
467 | efficient that the former. | |
468 | ||
0a47030a | 469 | |
e41182b5 GS |
470 | =head2 Security |
471 | ||
0a47030a GS |
472 | Most multi-user platforms provide basic levels of security that is usually |
473 | felt at the file-system level. Other platforms usually don't | |
474 | (unfortunately). Thus the notion of user id, or "home" directory, or even | |
475 | the state of being logged-in, may be unrecognizable on many platforms. If | |
6ab3f9cb | 476 | you write programs that are security-conscious, it is usually best to know |
0a47030a | 477 | what type of system you will be operating under, and write code explicitly |
e41182b5 GS |
478 | for that platform (or class of platforms). |
479 | ||
0a47030a | 480 | |
e41182b5 GS |
481 | =head2 Style |
482 | ||
483 | For those times when it is necessary to have platform-specific code, | |
484 | consider keeping the platform-specific code in one place, making porting | |
6ab3f9cb | 485 | to other platforms easier. Use the Config module and the special |
0a47030a GS |
486 | variable C<$^O> to differentiate platforms, as described in |
487 | L<"PLATFORMS">. | |
e41182b5 | 488 | |
19799a22 GS |
489 | Be careful in the tests you supply with your module or programs. Often |
490 | module code is fully portable, but the tests are not. This occurs | |
491 | often when tests spawn off other processes or call external programs | |
492 | to aid in the testing, or when (as noted above) the tests assume certain | |
493 | things about the filesystem and paths. | |
6ab3f9cb GS |
494 | Be careful not to depend on a specific output style for errors, |
495 | such as when checking C<$@> after an C<eval>. Some platforms | |
496 | expect a certain output format, and perl on those platforms may | |
497 | have been adjusted accordingly. Most specifically, don't anchor | |
498 | a regex when testing an error value. | |
499 | ||
500 | $@ =~ /^I got an error!/ # may fail | |
501 | $@ =~ /I got an error!/ # probably better | |
502 | ||
e41182b5 | 503 | |
0a47030a | 504 | =head1 CPAN Testers |
e41182b5 | 505 | |
0a47030a GS |
506 | Modules uploaded to CPAN are tested by a variety of volunteers on |
507 | different platforms. These CPAN testers are notified by mail of each | |
e41182b5 | 508 | new upload, and reply to the list with PASS, FAIL, NA (not applicable to |
0a47030a | 509 | this platform), or UNKNOWN (unknown), along with any relevant notations. |
e41182b5 GS |
510 | |
511 | The purpose of the testing is twofold: one, to help developers fix any | |
0a47030a GS |
512 | problems in their code that crop up because of lack of testing on other |
513 | platforms; two, to provide users with information about whether or not | |
514 | a given module works on a given platform. | |
e41182b5 GS |
515 | |
516 | =over 4 | |
517 | ||
518 | =item Mailing list: cpan-testers@perl.org | |
519 | ||
6ab3f9cb | 520 | =item Testing results: C<http://www.perl.org/cpan-testers/> |
e41182b5 GS |
521 | |
522 | =back | |
523 | ||
524 | ||
525 | =head1 PLATFORMS | |
526 | ||
527 | As of version 5.002, Perl is built with a C<$^O> variable that | |
528 | indicates the operating system it was built on. This was implemented | |
529 | to help speed up code that would otherwise have to C<use Config;> and | |
530 | use the value of C<$Config{'osname'}>. Of course, to get | |
531 | detailed information about the system, looking into C<%Config> is | |
532 | certainly recommended. | |
533 | ||
6ab3f9cb GS |
534 | C<%Config> cannot always be trusted, however, |
535 | because it is built at compile time, and if perl was built in once | |
536 | place and transferred elsewhere, some values may be off, or the | |
537 | values may have been edited after the fact. | |
538 | ||
539 | ||
e41182b5 GS |
540 | =head2 Unix |
541 | ||
542 | Perl works on a bewildering variety of Unix and Unix-like platforms (see | |
543 | e.g. most of the files in the F<hints/> directory in the source code kit). | |
544 | On most of these systems, the value of C<$^O> (hence C<$Config{'osname'}>, | |
545 | too) is determined by lowercasing and stripping punctuation from the first | |
0a47030a GS |
546 | field of the string returned by typing C<uname -a> (or a similar command) |
547 | at the shell prompt. Here, for example, are a few of the more popular | |
548 | Unix flavors: | |
e41182b5 | 549 | |
19799a22 | 550 | uname $^O $Config{'archname'} |
6ab3f9cb | 551 | -------------------------------------------- |
19799a22 | 552 | AIX aix aix |
6ab3f9cb GS |
553 | BSD/OS bsdos i386-bsdos |
554 | dgux dgux AViiON-dgux | |
555 | DYNIX/ptx dynixptx i386-dynixptx | |
19799a22 GS |
556 | FreeBSD freebsd freebsd-i386 |
557 | Linux linux i386-linux | |
6ab3f9cb GS |
558 | Linux linux i586-linux |
559 | Linux linux ppc-linux | |
19799a22 GS |
560 | HP-UX hpux PA-RISC1.1 |
561 | IRIX irix irix | |
6ab3f9cb | 562 | openbsd openbsd i386-openbsd |
19799a22 | 563 | OSF1 dec_osf alpha-dec_osf |
6ab3f9cb GS |
564 | reliantunix-n svr4 RM400-svr4 |
565 | SCO_SV sco_sv i386-sco_sv | |
566 | SINIX-N svr4 RM400-svr4 | |
567 | sn4609 unicos CRAY_C90-unicos | |
568 | sn6521 unicosmk t3e-unicosmk | |
569 | sn9617 unicos CRAY_J90-unicos | |
19799a22 GS |
570 | SunOS solaris sun4-solaris |
571 | SunOS solaris i86pc-solaris | |
572 | SunOS4 sunos sun4-sunos | |
e41182b5 | 573 | |
322422de GS |
574 | Note that because the C<$Config{'archname'}> may depend on the hardware |
575 | architecture it may vary quite a lot, much more than the C<$^O>. | |
e41182b5 | 576 | |
6ab3f9cb | 577 | |
e41182b5 GS |
578 | =head2 DOS and Derivatives |
579 | ||
580 | Perl has long been ported to PC style microcomputers running under | |
581 | systems like PC-DOS, MS-DOS, OS/2, and most Windows platforms you can | |
582 | bring yourself to mention (except for Windows CE, if you count that). | |
583 | Users familiar with I<COMMAND.COM> and/or I<CMD.EXE> style shells should | |
584 | be aware that each of these file specifications may have subtle | |
585 | differences: | |
586 | ||
587 | $filespec0 = "c:/foo/bar/file.txt"; | |
588 | $filespec1 = "c:\\foo\\bar\\file.txt"; | |
589 | $filespec2 = 'c:\foo\bar\file.txt'; | |
590 | $filespec3 = 'c:\\foo\\bar\\file.txt'; | |
591 | ||
592 | System calls accept either C</> or C<\> as the path separator. However, | |
593 | many command-line utilities of DOS vintage treat C</> as the option | |
594 | prefix, so they may get confused by filenames containing C</>. Aside | |
595 | from calling any external programs, C</> will work just fine, and | |
596 | probably better, as it is more consistent with popular usage, and avoids | |
597 | the problem of remembering what to backwhack and what not to. | |
598 | ||
0a47030a | 599 | The DOS FAT filesystem can only accommodate "8.3" style filenames. Under |
e41182b5 | 600 | the "case insensitive, but case preserving" HPFS (OS/2) and NTFS (NT) |
0a47030a | 601 | filesystems you may have to be careful about case returned with functions |
e41182b5 GS |
602 | like C<readdir> or used with functions like C<open> or C<opendir>. |
603 | ||
604 | DOS also treats several filenames as special, such as AUX, PRN, NUL, CON, | |
605 | COM1, LPT1, LPT2 etc. Unfortunately these filenames won't even work | |
606 | if you include an explicit directory prefix, in some cases. It is best | |
607 | to avoid such filenames, if you want your code to be portable to DOS | |
608 | and its derivatives. | |
609 | ||
610 | Users of these operating systems may also wish to make use of | |
6ab3f9cb | 611 | scripts such as F<pl2bat.bat> or F<pl2cmd> as appropriate to |
e41182b5 GS |
612 | put wrappers around your scripts. |
613 | ||
614 | Newline (C<\n>) is translated as C<\015\012> by STDIO when reading from | |
6ab3f9cb GS |
615 | and writing to files (see L<"Newlines">). C<binmode(FILEHANDLE)> |
616 | will keep C<\n> translated as C<\012> for that filehandle. Since it is a | |
617 | no-op on other systems, C<binmode> should be used for cross-platform code | |
618 | that deals with binary data. | |
e41182b5 GS |
619 | |
620 | The C<$^O> variable and the C<$Config{'archname'}> values for various | |
621 | DOSish perls are as follows: | |
622 | ||
623 | OS $^O $Config{'archname'} | |
624 | -------------------------------------------- | |
625 | MS-DOS dos | |
626 | PC-DOS dos | |
627 | OS/2 os2 | |
628 | Windows 95 MSWin32 MSWin32-x86 | |
6ab3f9cb | 629 | Windows 98 MSWin32 MSWin32-x86 |
e41182b5 | 630 | Windows NT MSWin32 MSWin32-x86 |
6ab3f9cb | 631 | Windows NT MSWin32 MSWin32-ALPHA |
e41182b5 GS |
632 | Windows NT MSWin32 MSWin32-ppc |
633 | ||
634 | Also see: | |
635 | ||
636 | =over 4 | |
637 | ||
638 | =item The djgpp environment for DOS, C<http://www.delorie.com/djgpp/> | |
639 | ||
640 | =item The EMX environment for DOS, OS/2, etc. C<emx@iaehv.nl>, | |
2ee0eb3c CN |
641 | C<http://www.leo.org/pub/comp/os/os2/leo/gnu/emx+gcc/index.html> or |
642 | C<ftp://hobbes.nmsu.edu/pub/os2/dev/emx> | |
e41182b5 GS |
643 | |
644 | =item Build instructions for Win32, L<perlwin32>. | |
645 | ||
646 | =item The ActiveState Pages, C<http://www.activestate.com/> | |
647 | ||
648 | =back | |
649 | ||
650 | ||
dd9f0070 | 651 | =head2 S<Mac OS> |
e41182b5 GS |
652 | |
653 | Any module requiring XS compilation is right out for most people, because | |
654 | MacPerl is built using non-free (and non-cheap!) compilers. Some XS | |
655 | modules that can work with MacPerl are built and distributed in binary | |
6ab3f9cb | 656 | form on CPAN. |
e41182b5 GS |
657 | |
658 | Directories are specified as: | |
659 | ||
660 | volume:folder:file for absolute pathnames | |
661 | volume:folder: for absolute pathnames | |
662 | :folder:file for relative pathnames | |
663 | :folder: for relative pathnames | |
664 | :file for relative pathnames | |
665 | file for relative pathnames | |
666 | ||
667 | Files in a directory are stored in alphabetical order. Filenames are | |
6ab3f9cb GS |
668 | limited to 31 characters, and may include any character except for |
669 | null and C<:>, which is reserved as path separator. | |
e41182b5 | 670 | |
0a47030a | 671 | Instead of C<flock>, see C<FSpSetFLock> and C<FSpRstFLock> in the |
6ab3f9cb | 672 | Mac::Files module, or C<chmod(0444, ...)> and C<chmod(0666, ...)>. |
e41182b5 GS |
673 | |
674 | In the MacPerl application, you can't run a program from the command line; | |
675 | programs that expect C<@ARGV> to be populated can be edited with something | |
676 | like the following, which brings up a dialog box asking for the command | |
677 | line arguments. | |
678 | ||
679 | if (!@ARGV) { | |
680 | @ARGV = split /\s+/, MacPerl::Ask('Arguments?'); | |
681 | } | |
682 | ||
683 | A MacPerl script saved as a droplet will populate C<@ARGV> with the full | |
684 | pathnames of the files dropped onto the script. | |
685 | ||
686 | Mac users can use programs on a kind of command line under MPW (Macintosh | |
687 | Programmer's Workshop, a free development environment from Apple). | |
688 | MacPerl was first introduced as an MPW tool, and MPW can be used like a | |
689 | shell: | |
690 | ||
691 | perl myscript.plx some arguments | |
692 | ||
693 | ToolServer is another app from Apple that provides access to MPW tools | |
0a47030a | 694 | from MPW and the MacPerl app, which allows MacPerl programs to use |
e41182b5 GS |
695 | C<system>, backticks, and piped C<open>. |
696 | ||
697 | "S<Mac OS>" is the proper name for the operating system, but the value | |
698 | in C<$^O> is "MacOS". To determine architecture, version, or whether | |
699 | the application or MPW tool version is running, check: | |
700 | ||
701 | $is_app = $MacPerl::Version =~ /App/; | |
702 | $is_tool = $MacPerl::Version =~ /MPW/; | |
703 | ($version) = $MacPerl::Version =~ /^(\S+)/; | |
704 | $is_ppc = $MacPerl::Architecture eq 'MacPPC'; | |
705 | $is_68k = $MacPerl::Architecture eq 'Mac68K'; | |
706 | ||
6ab3f9cb GS |
707 | S<Mac OS X> and S<Mac OS X Server>, based on NeXT's OpenStep OS, will |
708 | (in theory) be able to run MacPerl natively, under the "Classic" | |
709 | environment. The new "Cocoa" environment (formerly called the "Yellow Box") | |
710 | may run a slightly modified version of MacPerl, using the Carbon interfaces. | |
711 | ||
712 | S<Mac OS X Server> and its Open Source version, Darwin, both run Unix | |
713 | perl natively (with a small number of patches). Full support for these | |
714 | is slated for perl5.006. | |
715 | ||
e41182b5 GS |
716 | |
717 | Also see: | |
718 | ||
719 | =over 4 | |
720 | ||
6ab3f9cb | 721 | =item The MacPerl Pages, C<http://www.macperl.com/>. |
e41182b5 | 722 | |
6ab3f9cb GS |
723 | =item The MacPerl mailing lists, C<http://www.macperl.org/>. |
724 | ||
725 | =item MacPerl Module Porters, C<http://pudge.net/mmp/>. | |
e41182b5 GS |
726 | |
727 | =back | |
728 | ||
729 | ||
730 | =head2 VMS | |
731 | ||
732 | Perl on VMS is discussed in F<vms/perlvms.pod> in the perl distribution. | |
0a47030a | 733 | Note that perl on VMS can accept either VMS- or Unix-style file |
e41182b5 GS |
734 | specifications as in either of the following: |
735 | ||
736 | $ perl -ne "print if /perl_setup/i" SYS$LOGIN:LOGIN.COM | |
737 | $ perl -ne "print if /perl_setup/i" /sys$login/login.com | |
738 | ||
739 | but not a mixture of both as in: | |
740 | ||
741 | $ perl -ne "print if /perl_setup/i" sys$login:/login.com | |
742 | Can't open sys$login:/login.com: file specification syntax error | |
743 | ||
744 | Interacting with Perl from the Digital Command Language (DCL) shell | |
745 | often requires a different set of quotation marks than Unix shells do. | |
746 | For example: | |
747 | ||
748 | $ perl -e "print ""Hello, world.\n""" | |
749 | Hello, world. | |
750 | ||
751 | There are a number of ways to wrap your perl scripts in DCL .COM files if | |
752 | you are so inclined. For example: | |
753 | ||
754 | $ write sys$output "Hello from DCL!" | |
755 | $ if p1 .eqs. "" | |
756 | $ then perl -x 'f$environment("PROCEDURE") | |
757 | $ else perl -x - 'p1 'p2 'p3 'p4 'p5 'p6 'p7 'p8 | |
758 | $ deck/dollars="__END__" | |
759 | #!/usr/bin/perl | |
760 | ||
761 | print "Hello from Perl!\n"; | |
762 | ||
763 | __END__ | |
764 | $ endif | |
765 | ||
766 | Do take care with C<$ ASSIGN/nolog/user SYS$COMMAND: SYS$INPUT> if your | |
767 | perl-in-DCL script expects to do things like C<$read = E<lt>STDINE<gt>;>. | |
768 | ||
769 | Filenames are in the format "name.extension;version". The maximum | |
770 | length for filenames is 39 characters, and the maximum length for | |
771 | extensions is also 39 characters. Version is a number from 1 to | |
772 | 32767. Valid characters are C</[A-Z0-9$_-]/>. | |
773 | ||
774 | VMS' RMS filesystem is case insensitive and does not preserve case. | |
775 | C<readdir> returns lowercased filenames, but specifying a file for | |
b8099c3d | 776 | opening remains case insensitive. Files without extensions have a |
e41182b5 | 777 | trailing period on them, so doing a C<readdir> with a file named F<A.;5> |
0a47030a GS |
778 | will return F<a.> (though that file could be opened with |
779 | C<open(FH, 'A')>). | |
e41182b5 | 780 | |
f34d0673 | 781 | RMS had an eight level limit on directory depths from any rooted logical |
dd9f0070 CN |
782 | (allowing 16 levels overall) prior to VMS 7.2. Hence |
783 | C<PERL_ROOT:[LIB.2.3.4.5.6.7.8]> is a valid directory specification but | |
784 | C<PERL_ROOT:[LIB.2.3.4.5.6.7.8.9]> is not. F<Makefile.PL> authors might | |
785 | have to take this into account, but at least they can refer to the former | |
f34d0673 | 786 | as C</PERL_ROOT/lib/2/3/4/5/6/7/8/>. |
e41182b5 | 787 | |
6ab3f9cb | 788 | The VMS::Filespec module, which gets installed as part of the build |
0a47030a GS |
789 | process on VMS, is a pure Perl module that can easily be installed on |
790 | non-VMS platforms and can be helpful for conversions to and from RMS | |
791 | native formats. | |
e41182b5 GS |
792 | |
793 | What C<\n> represents depends on the type of file that is open. It could | |
794 | be C<\015>, C<\012>, C<\015\012>, or nothing. Reading from a file | |
795 | translates newlines to C<\012>, unless C<binmode> was executed on that | |
796 | handle, just like DOSish perls. | |
797 | ||
798 | TCP/IP stacks are optional on VMS, so socket routines might not be | |
799 | implemented. UDP sockets may not be supported. | |
800 | ||
801 | The value of C<$^O> on OpenVMS is "VMS". To determine the architecture | |
802 | that you are running on without resorting to loading all of C<%Config> | |
803 | you can examine the content of the C<@INC> array like so: | |
804 | ||
805 | if (grep(/VMS_AXP/, @INC)) { | |
806 | print "I'm on Alpha!\n"; | |
6ab3f9cb | 807 | |
e41182b5 GS |
808 | } elsif (grep(/VMS_VAX/, @INC)) { |
809 | print "I'm on VAX!\n"; | |
6ab3f9cb | 810 | |
e41182b5 GS |
811 | } else { |
812 | print "I'm not so sure about where $^O is...\n"; | |
813 | } | |
814 | ||
6ab3f9cb GS |
815 | On VMS perl determines the UTC offset from the C<SYS$TIMEZONE_DIFFERENTIAL> |
816 | logical name. Though the VMS epoch began at 17-NOV-1858 00:00:00.00, | |
817 | calls to C<localtime> are adjusted to count offsets from | |
818 | 01-JAN-1970 00:00:00.00 just like Unix. | |
819 | ||
e41182b5 GS |
820 | Also see: |
821 | ||
822 | =over 4 | |
823 | ||
824 | =item L<perlvms.pod> | |
825 | ||
6ab3f9cb | 826 | =item vmsperl list, C<majordomo@perl.org> |
e41182b5 | 827 | |
6ab3f9cb | 828 | Put the words C<subscribe vmsperl> in message body. |
e41182b5 GS |
829 | |
830 | =item vmsperl on the web, C<http://www.sidhe.org/vmsperl/index.html> | |
831 | ||
832 | =back | |
833 | ||
834 | ||
495c5fdc PG |
835 | =head2 VOS |
836 | ||
837 | Perl on VOS is discussed in F<README.vos> in the perl distribution. | |
838 | Note that perl on VOS can accept either VOS- or Unix-style file | |
839 | specifications as in either of the following: | |
840 | ||
841 | $ perl -ne "print if /perl_setup/i" >system>notices | |
842 | $ perl -ne "print if /perl_setup/i" /system/notices | |
843 | ||
844 | or even a mixture of both as in: | |
845 | ||
846 | $ perl -ne "print if /perl_setup/i" >system/notices | |
847 | ||
848 | Note that even though VOS allows the slash character to appear in object | |
849 | names, because the VOS port of Perl interprets it as a pathname | |
850 | delimiting character, VOS files, directories, or links whose names | |
851 | contain a slash character cannot be processed. Such files must be | |
852 | renamed before they can be processed by Perl. | |
853 | ||
2ee0eb3c | 854 | The following C functions are unimplemented on VOS, and any attempt by |
495c5fdc | 855 | Perl to use them will result in a fatal error message and an immediate |
2ee0eb3c CN |
856 | exit from Perl: dup, do_aspawn, do_spawn, fork, waitpid. Once these |
857 | functions become available in the VOS POSIX.1 implementation, you can | |
858 | either recompile and rebind Perl, or you can download a newer port from | |
859 | ftp.stratus.com. | |
495c5fdc PG |
860 | |
861 | The value of C<$^O> on VOS is "VOS". To determine the architecture that | |
862 | you are running on without resorting to loading all of C<%Config> you | |
863 | can examine the content of the C<@INC> array like so: | |
864 | ||
865 | if (grep(/VOS/, @INC)) { | |
866 | print "I'm on a Stratus box!\n"; | |
867 | } else { | |
868 | print "I'm not on a Stratus box!\n"; | |
869 | die; | |
870 | } | |
871 | ||
872 | if (grep(/860/, @INC)) { | |
873 | print "This box is a Stratus XA/R!\n"; | |
6ab3f9cb | 874 | |
495c5fdc PG |
875 | } elsif (grep(/7100/, @INC)) { |
876 | print "This box is a Stratus HP 7100 or 8000!\n"; | |
6ab3f9cb | 877 | |
495c5fdc PG |
878 | } elsif (grep(/8000/, @INC)) { |
879 | print "This box is a Stratus HP 8000!\n"; | |
6ab3f9cb | 880 | |
495c5fdc PG |
881 | } else { |
882 | print "This box is a Stratus 68K...\n"; | |
883 | } | |
884 | ||
885 | Also see: | |
886 | ||
887 | =over 4 | |
888 | ||
889 | =item L<README.vos> | |
890 | ||
891 | =item VOS mailing list | |
892 | ||
893 | There is no specific mailing list for Perl on VOS. You can post | |
894 | comments to the comp.sys.stratus newsgroup, or subscribe to the general | |
895 | Stratus mailing list. Send a letter with "Subscribe Info-Stratus" in | |
896 | the message body to majordomo@list.stratagy.com. | |
897 | ||
898 | =item VOS Perl on the web at C<http://ftp.stratus.com/pub/vos/vos.html> | |
899 | ||
900 | =back | |
901 | ||
902 | ||
e41182b5 GS |
903 | =head2 EBCDIC Platforms |
904 | ||
905 | Recent versions of Perl have been ported to platforms such as OS/400 on | |
7c5ffed3 JH |
906 | AS/400 minicomputers as well as OS/390 & VM/ESA for IBM Mainframes. Such |
907 | computers use EBCDIC character sets internally (usually Character Code | |
908 | Set ID 00819 for OS/400 and IBM-1047 for OS/390 & VM/ESA). Note that on | |
909 | the mainframe perl currently works under the "Unix system services | |
910 | for OS/390" (formerly known as OpenEdition) and VM/ESA OpenEdition. | |
e41182b5 | 911 | |
7c5ffed3 JH |
912 | As of R2.5 of USS for OS/390 and Version 2.3 of VM/ESA these Unix |
913 | sub-systems do not support the C<#!> shebang trick for script invocation. | |
914 | Hence, on OS/390 and VM/ESA perl scripts can be executed with a header | |
915 | similar to the following simple script: | |
e41182b5 GS |
916 | |
917 | : # use perl | |
918 | eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}' | |
919 | if 0; | |
920 | #!/usr/local/bin/perl # just a comment really | |
921 | ||
922 | print "Hello from perl!\n"; | |
923 | ||
6ab3f9cb GS |
924 | On the AS/400, assuming that PERL5 is in your library list, you may need |
925 | to wrap your perl scripts in a CL procedure to invoke them like so: | |
926 | ||
927 | BEGIN | |
928 | CALL PGM(PERL5/PERL) PARM('/QOpenSys/hello.pl') | |
929 | ENDPGM | |
930 | ||
931 | This will invoke the perl script F<hello.pl> in the root of the | |
932 | QOpenSys file system. On the AS/400 calls to C<system> or backticks | |
933 | must use CL syntax. | |
934 | ||
e41182b5 | 935 | On these platforms, bear in mind that the EBCDIC character set may have |
0a47030a GS |
936 | an effect on what happens with some perl functions (such as C<chr>, |
937 | C<pack>, C<print>, C<printf>, C<ord>, C<sort>, C<sprintf>, C<unpack>), as | |
938 | well as bit-fiddling with ASCII constants using operators like C<^>, C<&> | |
939 | and C<|>, not to mention dealing with socket interfaces to ASCII computers | |
6ab3f9cb | 940 | (see L<"Newlines">). |
e41182b5 GS |
941 | |
942 | Fortunately, most web servers for the mainframe will correctly translate | |
943 | the C<\n> in the following statement to its ASCII equivalent (note that | |
7c5ffed3 | 944 | C<\r> is the same under both Unix and OS/390 & VM/ESA): |
e41182b5 GS |
945 | |
946 | print "Content-type: text/html\r\n\r\n"; | |
947 | ||
948 | The value of C<$^O> on OS/390 is "os390". | |
949 | ||
7c5ffed3 | 950 | The value of C<$^O> on VM/ESA is "vmesa". |
3c075c7d | 951 | |
e41182b5 GS |
952 | Some simple tricks for determining if you are running on an EBCDIC |
953 | platform could include any of the following (perhaps all): | |
954 | ||
955 | if ("\t" eq "\05") { print "EBCDIC may be spoken here!\n"; } | |
956 | ||
957 | if (ord('A') == 193) { print "EBCDIC may be spoken here!\n"; } | |
958 | ||
959 | if (chr(169) eq 'z') { print "EBCDIC may be spoken here!\n"; } | |
960 | ||
961 | Note that one thing you may not want to rely on is the EBCDIC encoding | |
0a47030a GS |
962 | of punctuation characters since these may differ from code page to code |
963 | page (and once your module or script is rumoured to work with EBCDIC, | |
964 | folks will want it to work with all EBCDIC character sets). | |
e41182b5 GS |
965 | |
966 | Also see: | |
967 | ||
968 | =over 4 | |
969 | ||
970 | =item perl-mvs list | |
971 | ||
972 | The perl-mvs@perl.org list is for discussion of porting issues as well as | |
973 | general usage issues for all EBCDIC Perls. Send a message body of | |
974 | "subscribe perl-mvs" to majordomo@perl.org. | |
975 | ||
0a47030a | 976 | =item AS/400 Perl information at C<http://as400.rochester.ibm.com/> |
e41182b5 GS |
977 | |
978 | =back | |
979 | ||
b8099c3d CN |
980 | |
981 | =head2 Acorn RISC OS | |
982 | ||
0a47030a GS |
983 | As Acorns use ASCII with newlines (C<\n>) in text files as C<\012> like |
984 | Unix and Unix filename emulation is turned on by default, it is quite | |
985 | likely that most simple scripts will work "out of the box". The native | |
6ab3f9cb | 986 | filesystem is modular, and individual filesystems are free to be |
0a47030a | 987 | case-sensitive or insensitive, and are usually case-preserving. Some |
6ab3f9cb GS |
988 | native filesystems have name length limits which file and directory |
989 | names are silently truncated to fit. Scripts should be aware that the | |
990 | standard filesystem currently has a name length limit of B<10> | |
991 | characters, with up to 77 items in a directory, but other filesystems | |
0a47030a | 992 | may not impose such limitations. |
b8099c3d CN |
993 | |
994 | Native filenames are of the form | |
995 | ||
6ab3f9cb | 996 | Filesystem#Special_Field::DiskName.$.Directory.Directory.File |
dd9f0070 | 997 | |
b8099c3d CN |
998 | where |
999 | ||
1000 | Special_Field is not usually present, but may contain . and $ . | |
1001 | Filesystem =~ m|[A-Za-z0-9_]| | |
1002 | DsicName =~ m|[A-Za-z0-9_/]| | |
1003 | $ represents the root directory | |
1004 | . is the path separator | |
1005 | @ is the current directory (per filesystem but machine global) | |
1006 | ^ is the parent directory | |
1007 | Directory and File =~ m|[^\0- "\.\$\%\&:\@\\^\|\177]+| | |
1008 | ||
1009 | The default filename translation is roughly C<tr|/.|./|;> | |
1010 | ||
6ab3f9cb | 1011 | Note that C<"ADFS::HardDisk.$.File" ne 'ADFS::HardDisk.$.File'> and that |
0a47030a GS |
1012 | the second stage of C<$> interpolation in regular expressions will fall |
1013 | foul of the C<$.> if scripts are not careful. | |
1014 | ||
1015 | Logical paths specified by system variables containing comma-separated | |
1016 | search lists are also allowed, hence C<System:Modules> is a valid | |
1017 | filename, and the filesystem will prefix C<Modules> with each section of | |
6ab3f9cb | 1018 | C<System$Path> until a name is made that points to an object on disk. |
0a47030a GS |
1019 | Writing to a new file C<System:Modules> would only be allowed if |
1020 | C<System$Path> contains a single item list. The filesystem will also | |
1021 | expand system variables in filenames if enclosed in angle brackets, so | |
1022 | C<E<lt>System$DirE<gt>.Modules> would look for the file | |
1023 | S<C<$ENV{'System$Dir'} . 'Modules'>>. The obvious implication of this is | |
3c075c7d | 1024 | that B<fully qualified filenames can start with C<E<lt>E<gt>>> and should |
0a47030a | 1025 | be protected when C<open> is used for input. |
b8099c3d CN |
1026 | |
1027 | Because C<.> was in use as a directory separator and filenames could not | |
1028 | be assumed to be unique after 10 characters, Acorn implemented the C | |
1029 | compiler to strip the trailing C<.c> C<.h> C<.s> and C<.o> suffix from | |
1030 | filenames specified in source code and store the respective files in | |
1031 | subdirectories named after the suffix. Hence files are translated: | |
1032 | ||
1033 | foo.h h.foo | |
1034 | C:foo.h C:h.foo (logical path variable) | |
1035 | sys/os.h sys.h.os (C compiler groks Unix-speak) | |
1036 | 10charname.c c.10charname | |
1037 | 10charname.o o.10charname | |
1038 | 11charname_.c c.11charname (assuming filesystem truncates at 10) | |
1039 | ||
1040 | The Unix emulation library's translation of filenames to native assumes | |
0a47030a GS |
1041 | that this sort of translation is required, and allows a user defined list |
1042 | of known suffixes which it will transpose in this fashion. This may | |
1043 | appear transparent, but consider that with these rules C<foo/bar/baz.h> | |
1044 | and C<foo/bar/h/baz> both map to C<foo.bar.h.baz>, and that C<readdir> and | |
1045 | C<glob> cannot and do not attempt to emulate the reverse mapping. Other | |
6ab3f9cb | 1046 | C<.>'s in filenames are translated to C</>. |
0a47030a GS |
1047 | |
1048 | As implied above the environment accessed through C<%ENV> is global, and | |
1049 | the convention is that program specific environment variables are of the | |
6ab3f9cb GS |
1050 | form C<Program$Name>. Each filesystem maintains a current directory, |
1051 | and the current filesystem's current directory is the B<global> current | |
0a47030a GS |
1052 | directory. Consequently, sociable scripts don't change the current |
1053 | directory but rely on full pathnames, and scripts (and Makefiles) cannot | |
1054 | assume that they can spawn a child process which can change the current | |
1055 | directory without affecting its parent (and everyone else for that | |
1056 | matter). | |
1057 | ||
1058 | As native operating system filehandles are global and currently are | |
1059 | allocated down from 255, with 0 being a reserved value the Unix emulation | |
1060 | library emulates Unix filehandles. Consequently, you can't rely on | |
1061 | passing C<STDIN>, C<STDOUT>, or C<STDERR> to your children. | |
1062 | ||
1063 | The desire of users to express filenames of the form | |
1064 | C<E<lt>Foo$DirE<gt>.Bar> on the command line unquoted causes problems, | |
1065 | too: C<``> command output capture has to perform a guessing game. It | |
1066 | assumes that a string C<E<lt>[^E<lt>E<gt>]+\$[^E<lt>E<gt>]E<gt>> is a | |
1067 | reference to an environment variable, whereas anything else involving | |
1068 | C<E<lt>> or C<E<gt>> is redirection, and generally manages to be 99% | |
1069 | right. Of course, the problem remains that scripts cannot rely on any | |
1070 | Unix tools being available, or that any tools found have Unix-like command | |
1071 | line arguments. | |
1072 | ||
1073 | Extensions and XS are, in theory, buildable by anyone using free tools. | |
1074 | In practice, many don't, as users of the Acorn platform are used to binary | |
1075 | distribution. MakeMaker does run, but no available make currently copes | |
1076 | with MakeMaker's makefiles; even if/when this is fixed, the lack of a | |
1077 | Unix-like shell can cause problems with makefile rules, especially lines | |
1078 | of the form C<cd sdbm && make all>, and anything using quoting. | |
b8099c3d CN |
1079 | |
1080 | "S<RISC OS>" is the proper name for the operating system, but the value | |
1081 | in C<$^O> is "riscos" (because we don't like shouting). | |
1082 | ||
b8099c3d | 1083 | |
e41182b5 GS |
1084 | =head2 Other perls |
1085 | ||
b8099c3d | 1086 | Perl has been ported to a variety of platforms that do not fit into any of |
6ab3f9cb GS |
1087 | the above categories. Some, such as AmigaOS, Atari MiNT, BeOS, HP MPE/iX, |
1088 | QNX, Plan 9, and VOS, have been well-integrated into the standard Perl source | |
1089 | code kit. You may need to see the F<ports/> directory on CPAN for | |
1090 | information, and possibly binaries, for the likes of: aos, Atari ST, lynxos, | |
1091 | riscos, Novell Netware, Tandem Guardian, I<etc.> (yes we know that some of | |
1092 | these OSes may fall under the Unix category, but we are not a standards body.) | |
e41182b5 GS |
1093 | |
1094 | See also: | |
1095 | ||
1096 | =over 4 | |
1097 | ||
1098 | =item Atari, Guido Flohr's page C<http://stud.uni-sb.de/~gufl0000/> | |
1099 | ||
1100 | =item HP 300 MPE/iX C<http://www.cccd.edu/~markb/perlix.html> | |
1101 | ||
1102 | =item Novell Netware | |
1103 | ||
6ab3f9cb GS |
1104 | A free perl5-based PERL.NLM for Novell Netware is available in |
1105 | precompiled binary and source code form from C<http://www.novell.com/> | |
1106 | as well as from CPAN. | |
e41182b5 GS |
1107 | |
1108 | =back | |
1109 | ||
1110 | ||
1111 | =head1 FUNCTION IMPLEMENTATIONS | |
1112 | ||
1113 | Listed below are functions unimplemented or implemented differently on | |
1114 | various platforms. Following each description will be, in parentheses, a | |
1115 | list of platforms that the description applies to. | |
1116 | ||
1117 | The list may very well be incomplete, or wrong in some places. When in | |
1118 | doubt, consult the platform-specific README files in the Perl source | |
1119 | distribution, and other documentation resources for a given port. | |
1120 | ||
0a47030a | 1121 | Be aware, moreover, that even among Unix-ish systems there are variations. |
e41182b5 GS |
1122 | |
1123 | For many functions, you can also query C<%Config>, exported by default | |
6ab3f9cb GS |
1124 | from the Config module. For example, to check if the platform has the C<lstat> |
1125 | call, check C<$Config{'d_lstat'}>. See L<Config> for a full | |
0a47030a | 1126 | description of available variables. |
e41182b5 GS |
1127 | |
1128 | ||
1129 | =head2 Alphabetical Listing of Perl Functions | |
1130 | ||
1131 | =over 8 | |
1132 | ||
1133 | =item -X FILEHANDLE | |
1134 | ||
1135 | =item -X EXPR | |
1136 | ||
1137 | =item -X | |
1138 | ||
1139 | C<-r>, C<-w>, and C<-x> have only a very limited meaning; directories | |
1140 | and applications are executable, and there are no uid/gid | |
1141 | considerations. C<-o> is not supported. (S<Mac OS>) | |
1142 | ||
1143 | C<-r>, C<-w>, C<-x>, and C<-o> tell whether or not file is accessible, | |
1144 | which may not reflect UIC-based file protections. (VMS) | |
1145 | ||
b8099c3d CN |
1146 | C<-s> returns the size of the data fork, not the total size of data fork |
1147 | plus resource fork. (S<Mac OS>). | |
1148 | ||
1149 | C<-s> by name on an open file will return the space reserved on disk, | |
1150 | rather than the current extent. C<-s> on an open filehandle returns the | |
1151 | current size. (S<RISC OS>) | |
1152 | ||
e41182b5 | 1153 | C<-R>, C<-W>, C<-X>, C<-O> are indistinguishable from C<-r>, C<-w>, |
b8099c3d | 1154 | C<-x>, C<-o>. (S<Mac OS>, Win32, VMS, S<RISC OS>) |
e41182b5 GS |
1155 | |
1156 | C<-b>, C<-c>, C<-k>, C<-g>, C<-p>, C<-u>, C<-A> are not implemented. | |
1157 | (S<Mac OS>) | |
1158 | ||
1159 | C<-g>, C<-k>, C<-l>, C<-p>, C<-u>, C<-A> are not particularly meaningful. | |
b8099c3d | 1160 | (Win32, VMS, S<RISC OS>) |
e41182b5 GS |
1161 | |
1162 | C<-d> is true if passed a device spec without an explicit directory. | |
1163 | (VMS) | |
1164 | ||
1165 | C<-T> and C<-B> are implemented, but might misclassify Mac text files | |
0a47030a GS |
1166 | with foreign characters; this is the case will all platforms, but may |
1167 | affect S<Mac OS> often. (S<Mac OS>) | |
e41182b5 GS |
1168 | |
1169 | C<-x> (or C<-X>) determine if a file ends in one of the executable | |
1170 | suffixes. C<-S> is meaningless. (Win32) | |
1171 | ||
b8099c3d CN |
1172 | C<-x> (or C<-X>) determine if a file has an executable file type. |
1173 | (S<RISC OS>) | |
1174 | ||
e41182b5 GS |
1175 | =item binmode FILEHANDLE |
1176 | ||
b8099c3d | 1177 | Meaningless. (S<Mac OS>, S<RISC OS>) |
e41182b5 GS |
1178 | |
1179 | Reopens file and restores pointer; if function fails, underlying | |
1180 | filehandle may be closed, or pointer may be in a different position. | |
1181 | (VMS) | |
1182 | ||
1183 | The value returned by C<tell> may be affected after the call, and | |
1184 | the filehandle may be flushed. (Win32) | |
1185 | ||
1186 | =item chmod LIST | |
1187 | ||
1188 | Only limited meaning. Disabling/enabling write permission is mapped to | |
1189 | locking/unlocking the file. (S<Mac OS>) | |
1190 | ||
1191 | Only good for changing "owner" read-write access, "group", and "other" | |
1192 | bits are meaningless. (Win32) | |
1193 | ||
b8099c3d CN |
1194 | Only good for changing "owner" and "other" read-write access. (S<RISC OS>) |
1195 | ||
495c5fdc PG |
1196 | Access permissions are mapped onto VOS access-control list changes. (VOS) |
1197 | ||
e41182b5 GS |
1198 | =item chown LIST |
1199 | ||
495c5fdc | 1200 | Not implemented. (S<Mac OS>, Win32, Plan9, S<RISC OS>, VOS) |
e41182b5 GS |
1201 | |
1202 | Does nothing, but won't fail. (Win32) | |
1203 | ||
1204 | =item chroot FILENAME | |
1205 | ||
1206 | =item chroot | |
1207 | ||
7c5ffed3 | 1208 | Not implemented. (S<Mac OS>, Win32, VMS, Plan9, S<RISC OS>, VOS, VM/ESA) |
e41182b5 GS |
1209 | |
1210 | =item crypt PLAINTEXT,SALT | |
1211 | ||
1212 | May not be available if library or source was not provided when building | |
b8099c3d | 1213 | perl. (Win32) |
e41182b5 | 1214 | |
495c5fdc PG |
1215 | Not implemented. (VOS) |
1216 | ||
e41182b5 GS |
1217 | =item dbmclose HASH |
1218 | ||
495c5fdc | 1219 | Not implemented. (VMS, Plan9, VOS) |
e41182b5 GS |
1220 | |
1221 | =item dbmopen HASH,DBNAME,MODE | |
1222 | ||
495c5fdc | 1223 | Not implemented. (VMS, Plan9, VOS) |
e41182b5 GS |
1224 | |
1225 | =item dump LABEL | |
1226 | ||
b8099c3d | 1227 | Not useful. (S<Mac OS>, S<RISC OS>) |
e41182b5 GS |
1228 | |
1229 | Not implemented. (Win32) | |
1230 | ||
b8099c3d | 1231 | Invokes VMS debugger. (VMS) |
e41182b5 GS |
1232 | |
1233 | =item exec LIST | |
1234 | ||
1235 | Not implemented. (S<Mac OS>) | |
1236 | ||
7c5ffed3 | 1237 | Implemented via Spawn. (VM/ESA) |
3c075c7d | 1238 | |
e41182b5 GS |
1239 | =item fcntl FILEHANDLE,FUNCTION,SCALAR |
1240 | ||
1241 | Not implemented. (Win32, VMS) | |
1242 | ||
1243 | =item flock FILEHANDLE,OPERATION | |
1244 | ||
495c5fdc | 1245 | Not implemented (S<Mac OS>, VMS, S<RISC OS>, VOS). |
e41182b5 GS |
1246 | |
1247 | Available only on Windows NT (not on Windows 95). (Win32) | |
1248 | ||
1249 | =item fork | |
1250 | ||
7c5ffed3 | 1251 | Not implemented. (S<Mac OS>, Win32, AmigaOS, S<RISC OS>, VOS, VM/ESA) |
e41182b5 GS |
1252 | |
1253 | =item getlogin | |
1254 | ||
b8099c3d | 1255 | Not implemented. (S<Mac OS>, S<RISC OS>) |
e41182b5 GS |
1256 | |
1257 | =item getpgrp PID | |
1258 | ||
495c5fdc | 1259 | Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>, VOS) |
e41182b5 GS |
1260 | |
1261 | =item getppid | |
1262 | ||
b8099c3d | 1263 | Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>) |
e41182b5 GS |
1264 | |
1265 | =item getpriority WHICH,WHO | |
1266 | ||
7c5ffed3 | 1267 | Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>, VOS, VM/ESA) |
e41182b5 GS |
1268 | |
1269 | =item getpwnam NAME | |
1270 | ||
1271 | Not implemented. (S<Mac OS>, Win32) | |
1272 | ||
b8099c3d CN |
1273 | Not useful. (S<RISC OS>) |
1274 | ||
e41182b5 GS |
1275 | =item getgrnam NAME |
1276 | ||
b8099c3d | 1277 | Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>) |
e41182b5 GS |
1278 | |
1279 | =item getnetbyname NAME | |
1280 | ||
1281 | Not implemented. (S<Mac OS>, Win32, Plan9) | |
1282 | ||
1283 | =item getpwuid UID | |
1284 | ||
1285 | Not implemented. (S<Mac OS>, Win32) | |
1286 | ||
b8099c3d CN |
1287 | Not useful. (S<RISC OS>) |
1288 | ||
e41182b5 GS |
1289 | =item getgrgid GID |
1290 | ||
b8099c3d | 1291 | Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>) |
e41182b5 GS |
1292 | |
1293 | =item getnetbyaddr ADDR,ADDRTYPE | |
1294 | ||
1295 | Not implemented. (S<Mac OS>, Win32, Plan9) | |
1296 | ||
1297 | =item getprotobynumber NUMBER | |
1298 | ||
1299 | Not implemented. (S<Mac OS>) | |
1300 | ||
1301 | =item getservbyport PORT,PROTO | |
1302 | ||
1303 | Not implemented. (S<Mac OS>) | |
1304 | ||
1305 | =item getpwent | |
1306 | ||
7c5ffed3 | 1307 | Not implemented. (S<Mac OS>, Win32, VM/ESA) |
e41182b5 GS |
1308 | |
1309 | =item getgrent | |
1310 | ||
7c5ffed3 | 1311 | Not implemented. (S<Mac OS>, Win32, VMS, VM/ESA) |
e41182b5 GS |
1312 | |
1313 | =item gethostent | |
1314 | ||
1315 | Not implemented. (S<Mac OS>, Win32) | |
1316 | ||
1317 | =item getnetent | |
1318 | ||
1319 | Not implemented. (S<Mac OS>, Win32, Plan9) | |
1320 | ||
1321 | =item getprotoent | |
1322 | ||
1323 | Not implemented. (S<Mac OS>, Win32, Plan9) | |
1324 | ||
1325 | =item getservent | |
1326 | ||
1327 | Not implemented. (Win32, Plan9) | |
1328 | ||
1329 | =item setpwent | |
1330 | ||
b8099c3d | 1331 | Not implemented. (S<Mac OS>, Win32, S<RISC OS>) |
e41182b5 GS |
1332 | |
1333 | =item setgrent | |
1334 | ||
b8099c3d | 1335 | Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>) |
e41182b5 GS |
1336 | |
1337 | =item sethostent STAYOPEN | |
1338 | ||
b8099c3d | 1339 | Not implemented. (S<Mac OS>, Win32, Plan9, S<RISC OS>) |
e41182b5 GS |
1340 | |
1341 | =item setnetent STAYOPEN | |
1342 | ||
b8099c3d | 1343 | Not implemented. (S<Mac OS>, Win32, Plan9, S<RISC OS>) |
e41182b5 GS |
1344 | |
1345 | =item setprotoent STAYOPEN | |
1346 | ||
b8099c3d | 1347 | Not implemented. (S<Mac OS>, Win32, Plan9, S<RISC OS>) |
e41182b5 GS |
1348 | |
1349 | =item setservent STAYOPEN | |
1350 | ||
b8099c3d | 1351 | Not implemented. (Plan9, Win32, S<RISC OS>) |
e41182b5 GS |
1352 | |
1353 | =item endpwent | |
1354 | ||
7c5ffed3 | 1355 | Not implemented. (S<Mac OS>, Win32, VM/ESA) |
e41182b5 GS |
1356 | |
1357 | =item endgrent | |
1358 | ||
7c5ffed3 | 1359 | Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>, VM/ESA) |
e41182b5 GS |
1360 | |
1361 | =item endhostent | |
1362 | ||
1363 | Not implemented. (S<Mac OS>, Win32) | |
1364 | ||
1365 | =item endnetent | |
1366 | ||
1367 | Not implemented. (S<Mac OS>, Win32, Plan9) | |
1368 | ||
1369 | =item endprotoent | |
1370 | ||
1371 | Not implemented. (S<Mac OS>, Win32, Plan9) | |
1372 | ||
1373 | =item endservent | |
1374 | ||
1375 | Not implemented. (Plan9, Win32) | |
1376 | ||
1377 | =item getsockopt SOCKET,LEVEL,OPTNAME | |
1378 | ||
1379 | Not implemented. (S<Mac OS>, Plan9) | |
1380 | ||
1381 | =item glob EXPR | |
1382 | ||
1383 | =item glob | |
1384 | ||
1385 | Globbing built-in, but only C<*> and C<?> metacharacters are supported. | |
1386 | (S<Mac OS>) | |
1387 | ||
0a47030a GS |
1388 | Features depend on external perlglob.exe or perlglob.bat. May be |
1389 | overridden with something like File::DosGlob, which is recommended. | |
1390 | (Win32) | |
e41182b5 | 1391 | |
b8099c3d | 1392 | Globbing built-in, but only C<*> and C<?> metacharacters are supported. |
0a47030a GS |
1393 | Globbing relies on operating system calls, which may return filenames |
1394 | in any order. As most filesystems are case-insensitive, even "sorted" | |
1395 | filenames will not be in case-sensitive order. (S<RISC OS>) | |
b8099c3d | 1396 | |
e41182b5 GS |
1397 | =item ioctl FILEHANDLE,FUNCTION,SCALAR |
1398 | ||
1399 | Not implemented. (VMS) | |
1400 | ||
1401 | Available only for socket handles, and it does what the ioctlsocket() call | |
1402 | in the Winsock API does. (Win32) | |
1403 | ||
b8099c3d CN |
1404 | Available only for socket handles. (S<RISC OS>) |
1405 | ||
e41182b5 GS |
1406 | =item kill LIST |
1407 | ||
0a47030a GS |
1408 | Not implemented, hence not useful for taint checking. (S<Mac OS>, |
1409 | S<RISC OS>) | |
e41182b5 | 1410 | |
0a47030a GS |
1411 | Available only for process handles returned by the C<system(1, ...)> |
1412 | method of spawning a process. (Win32) | |
e41182b5 GS |
1413 | |
1414 | =item link OLDFILE,NEWFILE | |
1415 | ||
b8099c3d | 1416 | Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>) |
e41182b5 | 1417 | |
433acd8a JH |
1418 | Link count not updated because hard links are not quite that hard |
1419 | (They are sort of half-way between hard and soft links). (AmigaOS) | |
1420 | ||
e41182b5 GS |
1421 | =item lstat FILEHANDLE |
1422 | ||
1423 | =item lstat EXPR | |
1424 | ||
1425 | =item lstat | |
1426 | ||
b8099c3d | 1427 | Not implemented. (VMS, S<RISC OS>) |
e41182b5 | 1428 | |
b8099c3d | 1429 | Return values may be bogus. (Win32) |
e41182b5 GS |
1430 | |
1431 | =item msgctl ID,CMD,ARG | |
1432 | ||
1433 | =item msgget KEY,FLAGS | |
1434 | ||
1435 | =item msgsnd ID,MSG,FLAGS | |
1436 | ||
1437 | =item msgrcv ID,VAR,SIZE,TYPE,FLAGS | |
1438 | ||
495c5fdc | 1439 | Not implemented. (S<Mac OS>, Win32, VMS, Plan9, S<RISC OS>, VOS) |
e41182b5 GS |
1440 | |
1441 | =item open FILEHANDLE,EXPR | |
1442 | ||
1443 | =item open FILEHANDLE | |
1444 | ||
1445 | The C<|> variants are only supported if ToolServer is installed. | |
1446 | (S<Mac OS>) | |
1447 | ||
b8099c3d | 1448 | open to C<|-> and C<-|> are unsupported. (S<Mac OS>, Win32, S<RISC OS>) |
e41182b5 GS |
1449 | |
1450 | =item pipe READHANDLE,WRITEHANDLE | |
1451 | ||
1452 | Not implemented. (S<Mac OS>) | |
1453 | ||
433acd8a JH |
1454 | Very limited functionality. (MiNT) |
1455 | ||
e41182b5 GS |
1456 | =item readlink EXPR |
1457 | ||
1458 | =item readlink | |
1459 | ||
b8099c3d | 1460 | Not implemented. (Win32, VMS, S<RISC OS>) |
e41182b5 GS |
1461 | |
1462 | =item select RBITS,WBITS,EBITS,TIMEOUT | |
1463 | ||
1464 | Only implemented on sockets. (Win32) | |
1465 | ||
b8099c3d CN |
1466 | Only reliable on sockets. (S<RISC OS>) |
1467 | ||
e41182b5 GS |
1468 | =item semctl ID,SEMNUM,CMD,ARG |
1469 | ||
1470 | =item semget KEY,NSEMS,FLAGS | |
1471 | ||
1472 | =item semop KEY,OPSTRING | |
1473 | ||
495c5fdc | 1474 | Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>, VOS) |
e41182b5 GS |
1475 | |
1476 | =item setpgrp PID,PGRP | |
1477 | ||
495c5fdc | 1478 | Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>, VOS) |
e41182b5 GS |
1479 | |
1480 | =item setpriority WHICH,WHO,PRIORITY | |
1481 | ||
495c5fdc | 1482 | Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>, VOS) |
e41182b5 GS |
1483 | |
1484 | =item setsockopt SOCKET,LEVEL,OPTNAME,OPTVAL | |
1485 | ||
1486 | Not implemented. (S<Mac OS>, Plan9) | |
1487 | ||
1488 | =item shmctl ID,CMD,ARG | |
1489 | ||
1490 | =item shmget KEY,SIZE,FLAGS | |
1491 | ||
1492 | =item shmread ID,VAR,POS,SIZE | |
1493 | ||
1494 | =item shmwrite ID,STRING,POS,SIZE | |
1495 | ||
495c5fdc | 1496 | Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>, VOS) |
e41182b5 GS |
1497 | |
1498 | =item socketpair SOCKET1,SOCKET2,DOMAIN,TYPE,PROTOCOL | |
1499 | ||
7c5ffed3 | 1500 | Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>, VOS, VM/ESA) |
e41182b5 GS |
1501 | |
1502 | =item stat FILEHANDLE | |
1503 | ||
1504 | =item stat EXPR | |
1505 | ||
1506 | =item stat | |
1507 | ||
1508 | mtime and atime are the same thing, and ctime is creation time instead of | |
1509 | inode change time. (S<Mac OS>) | |
1510 | ||
1511 | device and inode are not meaningful. (Win32) | |
1512 | ||
1513 | device and inode are not necessarily reliable. (VMS) | |
1514 | ||
b8099c3d CN |
1515 | mtime, atime and ctime all return the last modification time. Device and |
1516 | inode are not necessarily reliable. (S<RISC OS>) | |
1517 | ||
e41182b5 GS |
1518 | =item symlink OLDFILE,NEWFILE |
1519 | ||
b8099c3d | 1520 | Not implemented. (Win32, VMS, S<RISC OS>) |
e41182b5 GS |
1521 | |
1522 | =item syscall LIST | |
1523 | ||
7c5ffed3 | 1524 | Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>, VOS, VM/ESA) |
e41182b5 | 1525 | |
f34d0673 GS |
1526 | =item sysopen FILEHANDLE,FILENAME,MODE,PERMS |
1527 | ||
dd9f0070 | 1528 | The traditional "0", "1", and "2" MODEs are implemented with different |
322422de GS |
1529 | numeric values on some systems. The flags exported by C<Fcntl> |
1530 | (O_RDONLY, O_WRONLY, O_RDWR) should work everywhere though. (S<Mac | |
7c5ffed3 | 1531 | OS>, OS/390, VM/ESA) |
f34d0673 | 1532 | |
e41182b5 GS |
1533 | =item system LIST |
1534 | ||
1535 | Only implemented if ToolServer is installed. (S<Mac OS>) | |
1536 | ||
1537 | As an optimization, may not call the command shell specified in | |
1538 | C<$ENV{PERL5SHELL}>. C<system(1, @args)> spawns an external | |
1539 | process and immediately returns its process designator, without | |
1540 | waiting for it to terminate. Return value may be used subsequently | |
1541 | in C<wait> or C<waitpid>. (Win32) | |
1542 | ||
b8099c3d CN |
1543 | There is no shell to process metacharacters, and the native standard is |
1544 | to pass a command line terminated by "\n" "\r" or "\0" to the spawned | |
1545 | program. Redirection such as C<E<gt> foo> is performed (if at all) by | |
1546 | the run time library of the spawned program. C<system> I<list> will call | |
1547 | the Unix emulation library's C<exec> emulation, which attempts to provide | |
1548 | emulation of the stdin, stdout, stderr in force in the parent, providing | |
1549 | the child program uses a compatible version of the emulation library. | |
1550 | I<scalar> will call the native command line direct and no such emulation | |
1551 | of a child Unix program will exists. Mileage B<will> vary. (S<RISC OS>) | |
1552 | ||
433acd8a JH |
1553 | Far from being POSIX compliant. Because there may be no underlying |
1554 | /bin/sh tries to work around the problem by forking and execing the | |
9b63e9ec CN |
1555 | first token in its argument string. Handles basic redirection |
1556 | ("E<lt>" or "E<gt>") on its own behalf. (MiNT) | |
433acd8a | 1557 | |
e41182b5 GS |
1558 | =item times |
1559 | ||
1560 | Only the first entry returned is nonzero. (S<Mac OS>) | |
1561 | ||
1562 | "cumulative" times will be bogus. On anything other than Windows NT, | |
1563 | "system" time will be bogus, and "user" time is actually the time | |
1564 | returned by the clock() function in the C runtime library. (Win32) | |
1565 | ||
b8099c3d CN |
1566 | Not useful. (S<RISC OS>) |
1567 | ||
e41182b5 GS |
1568 | =item truncate FILEHANDLE,LENGTH |
1569 | ||
1570 | =item truncate EXPR,LENGTH | |
1571 | ||
1572 | Not implemented. (VMS) | |
1573 | ||
495c5fdc PG |
1574 | Truncation to zero-length only. (VOS) |
1575 | ||
4cfdb94f GS |
1576 | If a FILEHANDLE is supplied, it must be writable and opened in append |
1577 | mode (i.e., use C<open(FH, '>>filename')> | |
1578 | or C<sysopen(FH,...,O_APPEND|O_RDWR)>. If a filename is supplied, it | |
1579 | should not be held open elsewhere. (Win32) | |
1580 | ||
e41182b5 GS |
1581 | =item umask EXPR |
1582 | ||
1583 | =item umask | |
1584 | ||
1585 | Returns undef where unavailable, as of version 5.005. | |
1586 | ||
9b63e9ec CN |
1587 | C<umask()> works but the correct permissions are only set when the file |
1588 | is finally close()d. (AmigaOS) | |
433acd8a | 1589 | |
e41182b5 GS |
1590 | =item utime LIST |
1591 | ||
b8099c3d | 1592 | Only the modification time is updated. (S<Mac OS>, VMS, S<RISC OS>) |
e41182b5 | 1593 | |
322422de GS |
1594 | May not behave as expected. Behavior depends on the C runtime |
1595 | library's implementation of utime(), and the filesystem being | |
1596 | used. The FAT filesystem typically does not support an "access | |
1597 | time" field, and it may limit timestamps to a granularity of | |
1598 | two seconds. (Win32) | |
e41182b5 GS |
1599 | |
1600 | =item wait | |
1601 | ||
1602 | =item waitpid PID,FLAGS | |
1603 | ||
495c5fdc | 1604 | Not implemented. (S<Mac OS>, VOS) |
e41182b5 GS |
1605 | |
1606 | Can only be applied to process handles returned for processes spawned | |
1607 | using C<system(1, ...)>. (Win32) | |
1608 | ||
b8099c3d CN |
1609 | Not useful. (S<RISC OS>) |
1610 | ||
e41182b5 GS |
1611 | =back |
1612 | ||
b8099c3d CN |
1613 | =head1 CHANGES |
1614 | ||
1615 | =over 4 | |
1616 | ||
19799a22 GS |
1617 | =item v1.42, 22 May 1999 |
1618 | Added notes about tests, sprintf/printf, and epoch offsets. | |
6ab3f9cb GS |
1619 | =item v1.41, 19 May 1999 |
1620 | ||
1621 | Lots more little changes to formatting and content. | |
1622 | ||
1623 | Added a bunch of <$^O> and related values | |
1624 | for various platforms; fixed mail and web addresses, and added | |
1625 | and changed miscellaneous notes. (Peter Prymmer) | |
1626 | ||
1627 | =item v1.40, 11 April 1999 | |
1628 | ||
1629 | Miscellaneous changes. | |
1630 | ||
1631 | =item v1.39, 11 February 1999 | |
2ee0eb3c CN |
1632 | |
1633 | Changes from Jarkko and EMX URL fixes Michael Schwern. Additional | |
1634 | note about newlines added. | |
1635 | ||
9b63e9ec CN |
1636 | =item v1.38, 31 December 1998 |
1637 | ||
1638 | More changes from Jarkko. | |
1639 | ||
3c075c7d CN |
1640 | =item v1.37, 19 December 1998 |
1641 | ||
1642 | More minor changes. Merge two separate version 1.35 documents. | |
1643 | ||
1644 | =item v1.36, 9 September 1998 | |
1645 | ||
1646 | Updated for Stratus VOS. Also known as version 1.35. | |
1647 | ||
1648 | =item v1.35, 13 August 1998 | |
495c5fdc | 1649 | |
3c075c7d CN |
1650 | Integrate more minor changes, plus addition of new sections under |
1651 | L<"ISSUES">: L<"Numbers endianness and Width">, | |
1652 | L<"Character sets and character encoding">, | |
1653 | L<"Internationalisation">. | |
495c5fdc | 1654 | |
3c075c7d | 1655 | =item v1.33, 06 August 1998 |
0a47030a GS |
1656 | |
1657 | Integrate more minor changes. | |
1658 | ||
3c075c7d | 1659 | =item v1.32, 05 August 1998 |
dd9f0070 CN |
1660 | |
1661 | Integrate more minor changes. | |
1662 | ||
3c075c7d | 1663 | =item v1.30, 03 August 1998 |
b8099c3d CN |
1664 | |
1665 | Major update for RISC OS, other minor changes. | |
1666 | ||
3c075c7d | 1667 | =item v1.23, 10 July 1998 |
b8099c3d CN |
1668 | |
1669 | First public release with perl5.005. | |
1670 | ||
1671 | =back | |
e41182b5 GS |
1672 | |
1673 | =head1 AUTHORS / CONTRIBUTORS | |
1674 | ||
dd9f0070 | 1675 | Abigail E<lt>abigail@fnx.comE<gt>, |
bd3fa61c | 1676 | Charles Bailey E<lt>bailey@newman.upenn.eduE<gt>, |
dd9f0070 | 1677 | Graham Barr E<lt>gbarr@pobox.comE<gt>, |
e41182b5 | 1678 | Tom Christiansen E<lt>tchrist@perl.comE<gt>, |
dd9f0070 CN |
1679 | Nicholas Clark E<lt>Nicholas.Clark@liverpool.ac.ukE<gt>, |
1680 | Andy Dougherty E<lt>doughera@lafcol.lafayette.eduE<gt>, | |
1681 | Dominic Dunlop E<lt>domo@vo.luE<gt>, | |
7c5ffed3 | 1682 | Neale Ferguson E<lt>neale@mailbox.tabnsw.com.auE<gt> |
495c5fdc | 1683 | Paul Green E<lt>Paul_Green@stratus.comE<gt>, |
dd9f0070 | 1684 | M.J.T. Guy E<lt>mjtg@cus.cam.ac.ukE<gt>, |
7c5ffed3 | 1685 | Jarkko Hietaniemi E<lt>jhi@iki.fi<gt>, |
dd9f0070 CN |
1686 | Luther Huffman E<lt>lutherh@stratcom.comE<gt>, |
1687 | Nick Ing-Simmons E<lt>nick@ni-s.u-net.comE<gt>, | |
322422de | 1688 | Andreas J. KE<ouml>nig E<lt>koenig@kulturbox.deE<gt>, |
3c075c7d | 1689 | Markus Laker E<lt>mlaker@contax.co.ukE<gt>, |
dd9f0070 | 1690 | Andrew M. Langmead E<lt>aml@world.std.comE<gt>, |
19799a22 | 1691 | Larry Moore E<lt>ljmoore@freespace.netE<gt>, |
e41182b5 | 1692 | Paul Moore E<lt>Paul.Moore@uk.origin-it.comE<gt>, |
dd9f0070 | 1693 | Chris Nandor E<lt>pudge@pobox.comE<gt>, |
322422de | 1694 | Matthias Neeracher E<lt>neeri@iis.ee.ethz.chE<gt>, |
e41182b5 | 1695 | Gary Ng E<lt>71564.1743@CompuServe.COME<gt>, |
e41182b5 | 1696 | Tom Phoenix E<lt>rootbeer@teleport.comE<gt>, |
dd9f0070 | 1697 | Peter Prymmer E<lt>pvhp@forte.comE<gt>, |
322422de | 1698 | Hugo van der Sanden E<lt>hv@crypt0.demon.co.ukE<gt>, |
dd9f0070 CN |
1699 | Gurusamy Sarathy E<lt>gsar@umich.eduE<gt>, |
1700 | Paul J. Schinder E<lt>schinder@pobox.comE<gt>, | |
2ee0eb3c | 1701 | Michael G Schwern E<lt>schwern@pobox.comE<gt>, |
e41182b5 | 1702 | Dan Sugalski E<lt>sugalskd@ous.eduE<gt>, |
dd9f0070 | 1703 | Nathan Torkington E<lt>gnat@frii.comE<gt>. |
e41182b5 | 1704 | |
3c075c7d CN |
1705 | This document is maintained by Chris Nandor |
1706 | E<lt>pudge@pobox.comE<gt>. | |
e41182b5 GS |
1707 | |
1708 | =head1 VERSION | |
1709 | ||
19799a22 | 1710 | Version 1.42, last modified 22 May 1999 |