1PERLPORT(1) Perl Programmers Reference Guide PERLPORT(1)
2
3
4
6 perlport - Writing portable Perl
7
9 Perl runs on numerous operating systems. While most of them share much
10 in common, they also have their own unique features.
11
12 This document is meant to help you to find out what constitutes
13 portable Perl code. That way once you make a decision to write
14 portably, you know where the lines are drawn, and you can stay within
15 them.
16
17 There is a tradeoff between taking full advantage of one particular
18 type of computer and taking advantage of a full range of them.
19 Naturally, as you broaden your range and become more diverse, the
20 common factors drop, and you are left with an increasingly smaller area
21 of common ground in which you can operate to accomplish a particular
22 task. Thus, when you begin attacking a problem, it is important to
23 consider under which part of the tradeoff curve you want to operate.
24 Specifically, you must decide whether it is important that the task
25 that you are coding have the full generality of being portable, or
26 whether to just get the job done right now. This is the hardest choice
27 to be made. The rest is easy, because Perl provides many choices,
28 whichever way you want to approach your problem.
29
30 Looking at it another way, writing portable code is usually about
31 willfully limiting your available choices. Naturally, it takes
32 discipline and sacrifice to do that. The product of portability and
33 convenience may be a constant. You have been warned.
34
35 Be aware of two important points:
36
37 Not all Perl programs have to be portable
38 There is no reason you should not use Perl as a language to glue
39 Unix tools together, or to prototype a Macintosh application, or to
40 manage the Windows registry. If it makes no sense to aim for
41 portability for one reason or another in a given program, then
42 don't bother.
43
44 Nearly all of Perl already is portable
45 Don't be fooled into thinking that it is hard to create portable
46 Perl code. It isn't. Perl tries its level-best to bridge the gaps
47 between what's available on different platforms, and all the means
48 available to use those features. Thus almost all Perl code runs on
49 any machine without modification. But there are some significant
50 issues in writing portable code, and this document is entirely
51 about those issues.
52
53 Here's the general rule: When you approach a task commonly done using a
54 whole range of platforms, think about writing portable code. That way,
55 you don't sacrifice much by way of the implementation choices you can
56 avail yourself of, and at the same time you can give your users lots of
57 platform choices. On the other hand, when you have to take advantage
58 of some unique feature of a particular platform, as is often the case
59 with systems programming (whether for Unix, Windows, Mac OS, VMS,
60 etc.), consider writing platform-specific code.
61
62 When the code will run on only two or three operating systems, you may
63 need to consider only the differences of those particular systems. The
64 important thing is to decide where the code will run and to be
65 deliberate in your decision.
66
67 The material below is separated into three main sections: main issues
68 of portability ("ISSUES"), platform-specific issues ("PLATFORMS"), and
69 built-in perl functions that behave differently on various ports
70 ("FUNCTION IMPLEMENTATIONS").
71
72 This information should not be considered complete; it includes
73 possibly transient information about idiosyncrasies of some of the
74 ports, almost all of which are in a state of constant evolution. Thus,
75 this material should be considered a perpetual work in progress ("<IMG
76 SRC="yellow_sign.gif" ALT="Under Construction">").
77
79 Newlines
80 In most operating systems, lines in files are terminated by newlines.
81 Just what is used as a newline may vary from OS to OS. Unix
82 traditionally uses "\012", one type of DOSish I/O uses "\015\012", and
83 Mac OS uses "\015".
84
85 Perl uses "\n" to represent the "logical" newline, where what is
86 logical may depend on the platform in use. In MacPerl, "\n" always
87 means "\015". In DOSish perls, "\n" usually means "\012", but when
88 accessing a file in "text" mode, STDIO translates it to (or from)
89 "\015\012", depending on whether you're reading or writing. Unix does
90 the same thing on ttys in canonical mode. "\015\012" is commonly
91 referred to as CRLF.
92
93 To trim trailing newlines from text lines use chomp(). With default
94 settings that function looks for a trailing "\n" character and thus
95 trims in a portable way.
96
97 When dealing with binary files (or text files in binary mode) be sure
98 to explicitly set $/ to the appropriate value for your file format
99 before using chomp().
100
101 Because of the "text" mode translation, DOSish perls have limitations
102 in using "seek" and "tell" on a file accessed in "text" mode. Stick to
103 "seek"-ing to locations you got from "tell" (and no others), and you
104 are usually free to use "seek" and "tell" even in "text" mode. Using
105 "seek" or "tell" or other file operations may be non-portable. If you
106 use "binmode" on a file, however, you can usually "seek" and "tell"
107 with arbitrary values in safety.
108
109 A common misconception in socket programming is that "\n" eq "\012"
110 everywhere. When using protocols such as common Internet protocols,
111 "\012" and "\015" are called for specifically, and the values of the
112 logical "\n" and "\r" (carriage return) are not reliable.
113
114 print SOCKET "Hi there, client!\r\n"; # WRONG
115 print SOCKET "Hi there, client!\015\012"; # RIGHT
116
117 However, using "\015\012" (or "\cM\cJ", or "\x0D\x0A") can be tedious
118 and unsightly, as well as confusing to those maintaining the code. As
119 such, the Socket module supplies the Right Thing for those who want it.
120
121 use Socket qw(:DEFAULT :crlf);
122 print SOCKET "Hi there, client!$CRLF" # RIGHT
123
124 When reading from a socket, remember that the default input record
125 separator $/ is "\n", but robust socket code will recognize as either
126 "\012" or "\015\012" as end of line:
127
128 while (<SOCKET>) {
129 # ...
130 }
131
132 Because both CRLF and LF end in LF, the input record separator can be
133 set to LF and any CR stripped later. Better to write:
134
135 use Socket qw(:DEFAULT :crlf);
136 local($/) = LF; # not needed if $/ is already \012
137
138 while (<SOCKET>) {
139 s/$CR?$LF/\n/; # not sure if socket uses LF or CRLF, OK
140 # s/\015?\012/\n/; # same thing
141 }
142
143 This example is preferred over the previous one--even for Unix
144 platforms--because now any "\015"'s ("\cM"'s) are stripped out (and
145 there was much rejoicing).
146
147 Similarly, functions that return text data--such as a function that
148 fetches a web page--should sometimes translate newlines before
149 returning the data, if they've not yet been translated to the local
150 newline representation. A single line of code will often suffice:
151
152 $data =~ s/\015?\012/\n/g;
153 return $data;
154
155 Some of this may be confusing. Here's a handy reference to the ASCII
156 CR and LF characters. You can print it out and stick it in your
157 wallet.
158
159 LF eq \012 eq \x0A eq \cJ eq chr(10) eq ASCII 10
160 CR eq \015 eq \x0D eq \cM eq chr(13) eq ASCII 13
161
162 | Unix | DOS | Mac |
163 ---------------------------
164 \n | LF | LF | CR |
165 \r | CR | CR | LF |
166 \n * | LF | CRLF | CR |
167 \r * | CR | CR | LF |
168 ---------------------------
169 * text-mode STDIO
170
171 The Unix column assumes that you are not accessing a serial line (like
172 a tty) in canonical mode. If you are, then CR on input becomes "\n",
173 and "\n" on output becomes CRLF.
174
175 These are just the most common definitions of "\n" and "\r" in Perl.
176 There may well be others. For example, on an EBCDIC implementation
177 such as z/OS (OS/390) or OS/400 (using the ILE, the PASE is ASCII-
178 based) the above material is similar to "Unix" but the code numbers
179 change:
180
181 LF eq \025 eq \x15 eq \cU eq chr(21) eq CP-1047 21
182 LF eq \045 eq \x25 eq chr(37) eq CP-0037 37
183 CR eq \015 eq \x0D eq \cM eq chr(13) eq CP-1047 13
184 CR eq \015 eq \x0D eq \cM eq chr(13) eq CP-0037 13
185
186 | z/OS | OS/400 |
187 ----------------------
188 \n | LF | LF |
189 \r | CR | CR |
190 \n * | LF | LF |
191 \r * | CR | CR |
192 ----------------------
193 * text-mode STDIO
194
195 Numbers endianness and Width
196 Different CPUs store integers and floating point numbers in different
197 orders (called endianness) and widths (32-bit and 64-bit being the most
198 common today). This affects your programs when they attempt to
199 transfer numbers in binary format from one CPU architecture to another,
200 usually either "live" via network connection, or by storing the numbers
201 to secondary storage such as a disk file or tape.
202
203 Conflicting storage orders make utter mess out of the numbers. If a
204 little-endian host (Intel, VAX) stores 0x12345678 (305419896 in
205 decimal), a big-endian host (Motorola, Sparc, PA) reads it as
206 0x78563412 (2018915346 in decimal). Alpha and MIPS can be either:
207 Digital/Compaq used/uses them in little-endian mode; SGI/Cray uses them
208 in big-endian mode. To avoid this problem in network (socket)
209 connections use the "pack" and "unpack" formats "n" and "N", the
210 "network" orders. These are guaranteed to be portable.
211
212 As of perl 5.9.2, you can also use the ">" and "<" modifiers to force
213 big- or little-endian byte-order. This is useful if you want to store
214 signed integers or 64-bit integers, for example.
215
216 You can explore the endianness of your platform by unpacking a data
217 structure packed in native format such as:
218
219 print unpack("h*", pack("s2", 1, 2)), "\n";
220 # '10002000' on e.g. Intel x86 or Alpha 21064 in little-endian mode
221 # '00100020' on e.g. Motorola 68040
222
223 If you need to distinguish between endian architectures you could use
224 either of the variables set like so:
225
226 $is_big_endian = unpack("h*", pack("s", 1)) =~ /01/;
227 $is_little_endian = unpack("h*", pack("s", 1)) =~ /^1/;
228
229 Differing widths can cause truncation even between platforms of equal
230 endianness. The platform of shorter width loses the upper parts of the
231 number. There is no good solution for this problem except to avoid
232 transferring or storing raw binary numbers.
233
234 One can circumnavigate both these problems in two ways. Either
235 transfer and store numbers always in text format, instead of raw
236 binary, or else consider using modules like Data::Dumper (included in
237 the standard distribution as of Perl 5.005) and Storable (included as
238 of perl 5.8). Keeping all data as text significantly simplifies
239 matters.
240
241 The v-strings are portable only up to v2147483647 (0x7FFFFFFF), that's
242 how far EBCDIC, or more precisely UTF-EBCDIC will go.
243
244 Files and Filesystems
245 Most platforms these days structure files in a hierarchical fashion.
246 So, it is reasonably safe to assume that all platforms support the
247 notion of a "path" to uniquely identify a file on the system. How that
248 path is really written, though, differs considerably.
249
250 Although similar, file path specifications differ between Unix,
251 Windows, Mac OS, OS/2, VMS, VOS, RISC OS, and probably others. Unix,
252 for example, is one of the few OSes that has the elegant idea of a
253 single root directory.
254
255 DOS, OS/2, VMS, VOS, and Windows can work similarly to Unix with "/" as
256 path separator, or in their own idiosyncratic ways (such as having
257 several root directories and various "unrooted" device files such NIL:
258 and LPT:).
259
260 Mac OS uses ":" as a path separator instead of "/".
261
262 The filesystem may support neither hard links ("link") nor symbolic
263 links ("symlink", "readlink", "lstat").
264
265 The filesystem may support neither access timestamp nor change
266 timestamp (meaning that about the only portable timestamp is the
267 modification timestamp), or one second granularity of any timestamps
268 (e.g. the FAT filesystem limits the time granularity to two seconds).
269
270 The "inode change timestamp" (the "-C" filetest) may really be the
271 "creation timestamp" (which it is not in UNIX).
272
273 VOS perl can emulate Unix filenames with "/" as path separator. The
274 native pathname characters greater-than, less-than, number-sign, and
275 percent-sign are always accepted.
276
277 RISC OS perl can emulate Unix filenames with "/" as path separator, or
278 go native and use "." for path separator and ":" to signal filesystems
279 and disk names.
280
281 Don't assume UNIX filesystem access semantics: that read, write, and
282 execute are all the permissions there are, and even if they exist, that
283 their semantics (for example what do r, w, and x mean on a directory)
284 are the UNIX ones. The various UNIX/POSIX compatibility layers usually
285 try to make interfaces like chmod() work, but sometimes there simply is
286 no good mapping.
287
288 If all this is intimidating, have no (well, maybe only a little) fear.
289 There are modules that can help. The File::Spec modules provide
290 methods to do the Right Thing on whatever platform happens to be
291 running the program.
292
293 use File::Spec::Functions;
294 chdir(updir()); # go up one directory
295 $file = catfile(curdir(), 'temp', 'file.txt');
296 # on Unix and Win32, './temp/file.txt'
297 # on Mac OS, ':temp:file.txt'
298 # on VMS, '[.temp]file.txt'
299
300 File::Spec is available in the standard distribution as of version
301 5.004_05. File::Spec::Functions is only in File::Spec 0.7 and later,
302 and some versions of perl come with version 0.6. If File::Spec is not
303 updated to 0.7 or later, you must use the object-oriented interface
304 from File::Spec (or upgrade File::Spec).
305
306 In general, production code should not have file paths hardcoded.
307 Making them user-supplied or read from a configuration file is better,
308 keeping in mind that file path syntax varies on different machines.
309
310 This is especially noticeable in scripts like Makefiles and test
311 suites, which often assume "/" as a path separator for subdirectories.
312
313 Also of use is File::Basename from the standard distribution, which
314 splits a pathname into pieces (base filename, full path to directory,
315 and file suffix).
316
317 Even when on a single platform (if you can call Unix a single
318 platform), remember not to count on the existence or the contents of
319 particular system-specific files or directories, like /etc/passwd,
320 /etc/sendmail.conf, /etc/resolv.conf, or even /tmp/. For example,
321 /etc/passwd may exist but not contain the encrypted passwords, because
322 the system is using some form of enhanced security. Or it may not
323 contain all the accounts, because the system is using NIS. If code
324 does need to rely on such a file, include a description of the file and
325 its format in the code's documentation, then make it easy for the user
326 to override the default location of the file.
327
328 Don't assume a text file will end with a newline. They should, but
329 people forget.
330
331 Do not have two files or directories of the same name with different
332 case, like test.pl and Test.pl, as many platforms have case-insensitive
333 (or at least case-forgiving) filenames. Also, try not to have non-word
334 characters (except for ".") in the names, and keep them to the 8.3
335 convention, for maximum portability, onerous a burden though this may
336 appear.
337
338 Likewise, when using the AutoSplit module, try to keep your functions
339 to 8.3 naming and case-insensitive conventions; or, at the least, make
340 it so the resulting files have a unique (case-insensitively) first 8
341 characters.
342
343 Whitespace in filenames is tolerated on most systems, but not all, and
344 even on systems where it might be tolerated, some utilities might
345 become confused by such whitespace.
346
347 Many systems (DOS, VMS ODS-2) cannot have more than one "." in their
348 filenames.
349
350 Don't assume ">" won't be the first character of a filename. Always
351 use "<" explicitly to open a file for reading, or even better, use the
352 three-arg version of open, unless you want the user to be able to
353 specify a pipe open.
354
355 open(FILE, '<', $existing_file) or die $!;
356
357 If filenames might use strange characters, it is safest to open it with
358 "sysopen" instead of "open". "open" is magic and can translate
359 characters like ">", "<", and "|", which may be the wrong thing to do.
360 (Sometimes, though, it's the right thing.) Three-arg open can also
361 help protect against this translation in cases where it is undesirable.
362
363 Don't use ":" as a part of a filename since many systems use that for
364 their own semantics (Mac OS Classic for separating pathname components,
365 many networking schemes and utilities for separating the nodename and
366 the pathname, and so on). For the same reasons, avoid "@", ";" and
367 "|".
368
369 Don't assume that in pathnames you can collapse two leading slashes
370 "//" into one: some networking and clustering filesystems have special
371 semantics for that. Let the operating system to sort it out.
372
373 The portable filename characters as defined by ANSI C are
374
375 a b c d e f g h i j k l m n o p q r t u v w x y z
376 A B C D E F G H I J K L M N O P Q R T U V W X Y Z
377 0 1 2 3 4 5 6 7 8 9
378 . _ -
379
380 and the "-" shouldn't be the first character. If you want to be
381 hypercorrect, stay case-insensitive and within the 8.3 naming
382 convention (all the files and directories have to be unique within one
383 directory if their names are lowercased and truncated to eight
384 characters before the ".", if any, and to three characters after the
385 ".", if any). (And do not use "."s in directory names.)
386
387 System Interaction
388 Not all platforms provide a command line. These are usually platforms
389 that rely primarily on a Graphical User Interface (GUI) for user
390 interaction. A program requiring a command line interface might not
391 work everywhere. This is probably for the user of the program to deal
392 with, so don't stay up late worrying about it.
393
394 Some platforms can't delete or rename files held open by the system,
395 this limitation may also apply to changing filesystem metainformation
396 like file permissions or owners. Remember to "close" files when you
397 are done with them. Don't "unlink" or "rename" an open file. Don't
398 "tie" or "open" a file already tied or opened; "untie" or "close" it
399 first.
400
401 Don't open the same file more than once at a time for writing, as some
402 operating systems put mandatory locks on such files.
403
404 Don't assume that write/modify permission on a directory gives the
405 right to add or delete files/directories in that directory. That is
406 filesystem specific: in some filesystems you need write/modify
407 permission also (or even just) in the file/directory itself. In some
408 filesystems (AFS, DFS) the permission to add/delete directory entries
409 is a completely separate permission.
410
411 Don't assume that a single "unlink" completely gets rid of the file:
412 some filesystems (most notably the ones in VMS) have versioned
413 filesystems, and unlink() removes only the most recent one (it doesn't
414 remove all the versions because by default the native tools on those
415 platforms remove just the most recent version, too). The portable
416 idiom to remove all the versions of a file is
417
418 1 while unlink "file";
419
420 This will terminate if the file is undeleteable for some reason
421 (protected, not there, and so on).
422
423 Don't count on a specific environment variable existing in %ENV. Don't
424 count on %ENV entries being case-sensitive, or even case-preserving.
425 Don't try to clear %ENV by saying "%ENV = ();", or, if you really have
426 to, make it conditional on "$^O ne 'VMS'" since in VMS the %ENV table
427 is much more than a per-process key-value string table.
428
429 On VMS, some entries in the %ENV hash are dynamically created when
430 their key is used on a read if they did not previously exist. The
431 values for $ENV{HOME}, $ENV{TERM}, $ENV{HOME}, and $ENV{USER}, are
432 known to be dynamically generated. The specific names that are
433 dynamically generated may vary with the version of the C library on
434 VMS, and more may exist than is documented.
435
436 On VMS by default, changes to the %ENV hash are persistent after the
437 process exits. This can cause unintended issues.
438
439 Don't count on signals or %SIG for anything.
440
441 Don't count on filename globbing. Use "opendir", "readdir", and
442 "closedir" instead.
443
444 Don't count on per-program environment variables, or per-program
445 current directories.
446
447 Don't count on specific values of $!, neither numeric nor especially
448 the strings values-- users may switch their locales causing error
449 messages to be translated into their languages. If you can trust a
450 POSIXish environment, you can portably use the symbols defined by the
451 Errno module, like ENOENT. And don't trust on the values of $! at all
452 except immediately after a failed system call.
453
454 Command names versus file pathnames
455 Don't assume that the name used to invoke a command or program with
456 "system" or "exec" can also be used to test for the existence of the
457 file that holds the executable code for that command or program.
458 First, many systems have "internal" commands that are built-in to the
459 shell or OS and while these commands can be invoked, there is no
460 corresponding file. Second, some operating systems (e.g., Cygwin,
461 DJGPP, OS/2, and VOS) have required suffixes for executable files;
462 these suffixes are generally permitted on the command name but are not
463 required. Thus, a command like "perl" might exist in a file named
464 "perl", "perl.exe", or "perl.pm", depending on the operating system.
465 The variable "_exe" in the Config module holds the executable suffix,
466 if any. Third, the VMS port carefully sets up $^X and
467 $Config{perlpath} so that no further processing is required. This is
468 just as well, because the matching regular expression used below would
469 then have to deal with a possible trailing version number in the VMS
470 file name.
471
472 To convert $^X to a file pathname, taking account of the requirements
473 of the various operating system possibilities, say:
474
475 use Config;
476 $thisperl = $^X;
477 if ($^O ne 'VMS')
478 {$thisperl .= $Config{_exe} unless $thisperl =~ m/$Config{_exe}$/i;}
479
480 To convert $Config{perlpath} to a file pathname, say:
481
482 use Config;
483 $thisperl = $Config{perlpath};
484 if ($^O ne 'VMS')
485 {$thisperl .= $Config{_exe} unless $thisperl =~ m/$Config{_exe}$/i;}
486
487 Networking
488 Don't assume that you can reach the public Internet.
489
490 Don't assume that there is only one way to get through firewalls to the
491 public Internet.
492
493 Don't assume that you can reach outside world through any other port
494 than 80, or some web proxy. ftp is blocked by many firewalls.
495
496 Don't assume that you can send email by connecting to the local SMTP
497 port.
498
499 Don't assume that you can reach yourself or any node by the name
500 'localhost'. The same goes for '127.0.0.1'. You will have to try
501 both.
502
503 Don't assume that the host has only one network card, or that it can't
504 bind to many virtual IP addresses.
505
506 Don't assume a particular network device name.
507
508 Don't assume a particular set of ioctl()s will work.
509
510 Don't assume that you can ping hosts and get replies.
511
512 Don't assume that any particular port (service) will respond.
513
514 Don't assume that Sys::Hostname (or any other API or command) returns
515 either a fully qualified hostname or a non-qualified hostname: it all
516 depends on how the system had been configured. Also remember things
517 like DHCP and NAT-- the hostname you get back might not be very useful.
518
519 All the above "don't":s may look daunting, and they are -- but the key
520 is to degrade gracefully if one cannot reach the particular network
521 service one wants. Croaking or hanging do not look very professional.
522
523 Interprocess Communication (IPC)
524 In general, don't directly access the system in code meant to be
525 portable. That means, no "system", "exec", "fork", "pipe", "``",
526 "qx//", "open" with a "|", nor any of the other things that makes being
527 a perl hacker worth being.
528
529 Commands that launch external processes are generally supported on most
530 platforms (though many of them do not support any type of forking).
531 The problem with using them arises from what you invoke them on.
532 External tools are often named differently on different platforms, may
533 not be available in the same location, might accept different
534 arguments, can behave differently, and often present their results in a
535 platform-dependent way. Thus, you should seldom depend on them to
536 produce consistent results. (Then again, if you're calling netstat -a,
537 you probably don't expect it to run on both Unix and CP/M.)
538
539 One especially common bit of Perl code is opening a pipe to sendmail:
540
541 open(MAIL, '|/usr/lib/sendmail -t')
542 or die "cannot fork sendmail: $!";
543
544 This is fine for systems programming when sendmail is known to be
545 available. But it is not fine for many non-Unix systems, and even some
546 Unix systems that may not have sendmail installed. If a portable
547 solution is needed, see the various distributions on CPAN that deal
548 with it. Mail::Mailer and Mail::Send in the MailTools distribution are
549 commonly used, and provide several mailing methods, including mail,
550 sendmail, and direct SMTP (via Net::SMTP) if a mail transfer agent is
551 not available. Mail::Sendmail is a standalone module that provides
552 simple, platform-independent mailing.
553
554 The Unix System V IPC ("msg*(), sem*(), shm*()") is not available even
555 on all Unix platforms.
556
557 Do not use either the bare result of "pack("N", 10, 20, 30, 40)" or
558 bare v-strings (such as "v10.20.30.40") to represent IPv4 addresses:
559 both forms just pack the four bytes into network order. That this
560 would be equal to the C language "in_addr" struct (which is what the
561 socket code internally uses) is not guaranteed. To be portable use the
562 routines of the Socket extension, such as "inet_aton()", "inet_ntoa()",
563 and "sockaddr_in()".
564
565 The rule of thumb for portable code is: Do it all in portable Perl, or
566 use a module (that may internally implement it with platform-specific
567 code, but expose a common interface).
568
569 External Subroutines (XS)
570 XS code can usually be made to work with any platform, but dependent
571 libraries, header files, etc., might not be readily available or
572 portable, or the XS code itself might be platform-specific, just as
573 Perl code might be. If the libraries and headers are portable, then it
574 is normally reasonable to make sure the XS code is portable, too.
575
576 A different type of portability issue arises when writing XS code:
577 availability of a C compiler on the end-user's system. C brings with
578 it its own portability issues, and writing XS code will expose you to
579 some of those. Writing purely in Perl is an easier way to achieve
580 portability.
581
582 Standard Modules
583 In general, the standard modules work across platforms. Notable
584 exceptions are the CPAN module (which currently makes connections to
585 external programs that may not be available), platform-specific modules
586 (like ExtUtils::MM_VMS), and DBM modules.
587
588 There is no one DBM module available on all platforms. SDBM_File and
589 the others are generally available on all Unix and DOSish ports, but
590 not in MacPerl, where only NBDM_File and DB_File are available.
591
592 The good news is that at least some DBM module should be available, and
593 AnyDBM_File will use whichever module it can find. Of course, then the
594 code needs to be fairly strict, dropping to the greatest common factor
595 (e.g., not exceeding 1K for each record), so that it will work with any
596 DBM module. See AnyDBM_File for more details.
597
598 Time and Date
599 The system's notion of time of day and calendar date is controlled in
600 widely different ways. Don't assume the timezone is stored in
601 $ENV{TZ}, and even if it is, don't assume that you can control the
602 timezone through that variable. Don't assume anything about the three-
603 letter timezone abbreviations (for example that MST would be the
604 Mountain Standard Time, it's been known to stand for Moscow Standard
605 Time). If you need to use timezones, express them in some unambiguous
606 format like the exact number of minutes offset from UTC, or the POSIX
607 timezone format.
608
609 Don't assume that the epoch starts at 00:00:00, January 1, 1970,
610 because that is OS- and implementation-specific. It is better to store
611 a date in an unambiguous representation. The ISO 8601 standard defines
612 YYYY-MM-DD as the date format, or YYYY-MM-DDTHH-MM-SS (that's a literal
613 "T" separating the date from the time). Please do use the ISO 8601
614 instead of making us to guess what date 02/03/04 might be. ISO 8601
615 even sorts nicely as-is. A text representation (like "1987-12-18") can
616 be easily converted into an OS-specific value using a module like
617 Date::Parse. An array of values, such as those returned by
618 "localtime", can be converted to an OS-specific representation using
619 Time::Local.
620
621 When calculating specific times, such as for tests in time or date
622 modules, it may be appropriate to calculate an offset for the epoch.
623
624 require Time::Local;
625 $offset = Time::Local::timegm(0, 0, 0, 1, 0, 70);
626
627 The value for $offset in Unix will be 0, but in Mac OS will be some
628 large number. $offset can then be added to a Unix time value to get
629 what should be the proper value on any system.
630
631 On Windows (at least), you shouldn't pass a negative value to "gmtime"
632 or "localtime".
633
634 Character sets and character encoding
635 Assume very little about character sets.
636
637 Assume nothing about numerical values ("ord", "chr") of characters. Do
638 not use explicit code point ranges (like \xHH-\xHH); use for example
639 symbolic character classes like "[:print:]".
640
641 Do not assume that the alphabetic characters are encoded contiguously
642 (in the numeric sense). There may be gaps.
643
644 Do not assume anything about the ordering of the characters. The
645 lowercase letters may come before or after the uppercase letters; the
646 lowercase and uppercase may be interlaced so that both "a" and "A" come
647 before "b"; the accented and other international characters may be
648 interlaced so that ae comes before "b".
649
650 Internationalisation
651 If you may assume POSIX (a rather large assumption), you may read more
652 about the POSIX locale system from perllocale. The locale system at
653 least attempts to make things a little bit more portable, or at least
654 more convenient and native-friendly for non-English users. The system
655 affects character sets and encoding, and date and time
656 formatting--amongst other things.
657
658 If you really want to be international, you should consider Unicode.
659 See perluniintro and perlunicode for more information.
660
661 If you want to use non-ASCII bytes (outside the bytes 0x00..0x7f) in
662 the "source code" of your code, to be portable you have to be explicit
663 about what bytes they are. Someone might for example be using your
664 code under a UTF-8 locale, in which case random native bytes might be
665 illegal ("Malformed UTF-8 ...") This means that for example embedding
666 ISO 8859-1 bytes beyond 0x7f into your strings might cause trouble
667 later. If the bytes are native 8-bit bytes, you can use the "bytes"
668 pragma. If the bytes are in a string (regular expression being a
669 curious string), you can often also use the "\xHH" notation instead of
670 embedding the bytes as-is. (If you want to write your code in UTF-8,
671 you can use the "utf8".) The "bytes" and "utf8" pragmata are available
672 since Perl 5.6.0.
673
674 System Resources
675 If your code is destined for systems with severely constrained (or
676 missing!) virtual memory systems then you want to be especially mindful
677 of avoiding wasteful constructs such as:
678
679 # NOTE: this is no longer "bad" in perl5.005
680 for (0..10000000) {} # bad
681 for (my $x = 0; $x <= 10000000; ++$x) {} # good
682
683 @lines = <VERY_LARGE_FILE>; # bad
684
685 while (<FILE>) {$file .= $_} # sometimes bad
686 $file = join('', <FILE>); # better
687
688 The last two constructs may appear unintuitive to most people. The
689 first repeatedly grows a string, whereas the second allocates a large
690 chunk of memory in one go. On some systems, the second is more
691 efficient that the first.
692
693 Security
694 Most multi-user platforms provide basic levels of security, usually
695 implemented at the filesystem level. Some, however, do not--
696 unfortunately. Thus the notion of user id, or "home" directory, or
697 even the state of being logged-in, may be unrecognizable on many
698 platforms. If you write programs that are security-conscious, it is
699 usually best to know what type of system you will be running under so
700 that you can write code explicitly for that platform (or class of
701 platforms).
702
703 Don't assume the UNIX filesystem access semantics: the operating system
704 or the filesystem may be using some ACL systems, which are richer
705 languages than the usual rwx. Even if the rwx exist, their semantics
706 might be different.
707
708 (From security viewpoint testing for permissions before attempting to
709 do something is silly anyway: if one tries this, there is potential for
710 race conditions-- someone or something might change the permissions
711 between the permissions check and the actual operation. Just try the
712 operation.)
713
714 Don't assume the UNIX user and group semantics: especially, don't
715 expect the $< and $> (or the $( and $)) to work for switching
716 identities (or memberships).
717
718 Don't assume set-uid and set-gid semantics. (And even if you do, think
719 twice: set-uid and set-gid are a known can of security worms.)
720
721 Style
722 For those times when it is necessary to have platform-specific code,
723 consider keeping the platform-specific code in one place, making
724 porting to other platforms easier. Use the Config module and the
725 special variable $^O to differentiate platforms, as described in
726 "PLATFORMS".
727
728 Be careful in the tests you supply with your module or programs.
729 Module code may be fully portable, but its tests might not be. This
730 often happens when tests spawn off other processes or call external
731 programs to aid in the testing, or when (as noted above) the tests
732 assume certain things about the filesystem and paths. Be careful not
733 to depend on a specific output style for errors, such as when checking
734 $! after a failed system call. Using $! for anything else than
735 displaying it as output is doubtful (though see the Errno module for
736 testing reasonably portably for error value). Some platforms expect a
737 certain output format, and Perl on those platforms may have been
738 adjusted accordingly. Most specifically, don't anchor a regex when
739 testing an error value.
740
742 Modules uploaded to CPAN are tested by a variety of volunteers on
743 different platforms. These CPAN testers are notified by mail of each
744 new upload, and reply to the list with PASS, FAIL, NA (not applicable
745 to this platform), or UNKNOWN (unknown), along with any relevant
746 notations.
747
748 The purpose of the testing is twofold: one, to help developers fix any
749 problems in their code that crop up because of lack of testing on other
750 platforms; two, to provide users with information about whether a given
751 module works on a given platform.
752
753 Also see:
754
755 · Mailing list: cpan-testers@perl.org
756
757 · Testing results: http://testers.cpan.org/
758
760 As of version 5.002, Perl is built with a $^O variable that indicates
761 the operating system it was built on. This was implemented to help
762 speed up code that would otherwise have to "use Config" and use the
763 value of $Config{osname}. Of course, to get more detailed information
764 about the system, looking into %Config is certainly recommended.
765
766 %Config cannot always be trusted, however, because it was built at
767 compile time. If perl was built in one place, then transferred
768 elsewhere, some values may be wrong. The values may even have been
769 edited after the fact.
770
771 Unix
772 Perl works on a bewildering variety of Unix and Unix-like platforms
773 (see e.g. most of the files in the hints/ directory in the source code
774 kit). On most of these systems, the value of $^O (hence
775 $Config{'osname'}, too) is determined either by lowercasing and
776 stripping punctuation from the first field of the string returned by
777 typing "uname -a" (or a similar command) at the shell prompt or by
778 testing the file system for the presence of uniquely named files such
779 as a kernel or header file. Here, for example, are a few of the more
780 popular Unix flavors:
781
782 uname $^O $Config{'archname'}
783 --------------------------------------------
784 AIX aix aix
785 BSD/OS bsdos i386-bsdos
786 Darwin darwin darwin
787 dgux dgux AViiON-dgux
788 DYNIX/ptx dynixptx i386-dynixptx
789 FreeBSD freebsd freebsd-i386
790 Haiku haiku BePC-haiku
791 Linux linux arm-linux
792 Linux linux i386-linux
793 Linux linux i586-linux
794 Linux linux ppc-linux
795 HP-UX hpux PA-RISC1.1
796 IRIX irix irix
797 Mac OS X darwin darwin
798 MachTen PPC machten powerpc-machten
799 NeXT 3 next next-fat
800 NeXT 4 next OPENSTEP-Mach
801 openbsd openbsd i386-openbsd
802 OSF1 dec_osf alpha-dec_osf
803 reliantunix-n svr4 RM400-svr4
804 SCO_SV sco_sv i386-sco_sv
805 SINIX-N svr4 RM400-svr4
806 sn4609 unicos CRAY_C90-unicos
807 sn6521 unicosmk t3e-unicosmk
808 sn9617 unicos CRAY_J90-unicos
809 SunOS solaris sun4-solaris
810 SunOS solaris i86pc-solaris
811 SunOS4 sunos sun4-sunos
812
813 Because the value of $Config{archname} may depend on the hardware
814 architecture, it can vary more than the value of $^O.
815
816 DOS and Derivatives
817 Perl has long been ported to Intel-style microcomputers running under
818 systems like PC-DOS, MS-DOS, OS/2, and most Windows platforms you can
819 bring yourself to mention (except for Windows CE, if you count that).
820 Users familiar with COMMAND.COM or CMD.EXE style shells should be aware
821 that each of these file specifications may have subtle differences:
822
823 $filespec0 = "c:/foo/bar/file.txt";
824 $filespec1 = "c:\\foo\\bar\\file.txt";
825 $filespec2 = 'c:\foo\bar\file.txt';
826 $filespec3 = 'c:\\foo\\bar\\file.txt';
827
828 System calls accept either "/" or "\" as the path separator. However,
829 many command-line utilities of DOS vintage treat "/" as the option
830 prefix, so may get confused by filenames containing "/". Aside from
831 calling any external programs, "/" will work just fine, and probably
832 better, as it is more consistent with popular usage, and avoids the
833 problem of remembering what to backwhack and what not to.
834
835 The DOS FAT filesystem can accommodate only "8.3" style filenames.
836 Under the "case-insensitive, but case-preserving" HPFS (OS/2) and NTFS
837 (NT) filesystems you may have to be careful about case returned with
838 functions like "readdir" or used with functions like "open" or
839 "opendir".
840
841 DOS also treats several filenames as special, such as AUX, PRN, NUL,
842 CON, COM1, LPT1, LPT2, etc. Unfortunately, sometimes these filenames
843 won't even work if you include an explicit directory prefix. It is
844 best to avoid such filenames, if you want your code to be portable to
845 DOS and its derivatives. It's hard to know what these all are,
846 unfortunately.
847
848 Users of these operating systems may also wish to make use of scripts
849 such as pl2bat.bat or pl2cmd to put wrappers around your scripts.
850
851 Newline ("\n") is translated as "\015\012" by STDIO when reading from
852 and writing to files (see "Newlines"). "binmode(FILEHANDLE)" will keep
853 "\n" translated as "\012" for that filehandle. Since it is a no-op on
854 other systems, "binmode" should be used for cross-platform code that
855 deals with binary data. That's assuming you realize in advance that
856 your data is in binary. General-purpose programs should often assume
857 nothing about their data.
858
859 The $^O variable and the $Config{archname} values for various DOSish
860 perls are as follows:
861
862 OS $^O $Config{archname} ID Version
863 --------------------------------------------------------
864 MS-DOS dos ?
865 PC-DOS dos ?
866 OS/2 os2 ?
867 Windows 3.1 ? ? 0 3 01
868 Windows 95 MSWin32 MSWin32-x86 1 4 00
869 Windows 98 MSWin32 MSWin32-x86 1 4 10
870 Windows ME MSWin32 MSWin32-x86 1 ?
871 Windows NT MSWin32 MSWin32-x86 2 4 xx
872 Windows NT MSWin32 MSWin32-ALPHA 2 4 xx
873 Windows NT MSWin32 MSWin32-ppc 2 4 xx
874 Windows 2000 MSWin32 MSWin32-x86 2 5 00
875 Windows XP MSWin32 MSWin32-x86 2 5 01
876 Windows 2003 MSWin32 MSWin32-x86 2 5 02
877 Windows CE MSWin32 ? 3
878 Cygwin cygwin cygwin
879
880 The various MSWin32 Perl's can distinguish the OS they are running on
881 via the value of the fifth element of the list returned from
882 Win32::GetOSVersion(). For example:
883
884 if ($^O eq 'MSWin32') {
885 my @os_version_info = Win32::GetOSVersion();
886 print +('3.1','95','NT')[$os_version_info[4]],"\n";
887 }
888
889 There are also Win32::IsWinNT() and Win32::IsWin95(), try "perldoc
890 Win32", and as of libwin32 0.19 (not part of the core Perl
891 distribution) Win32::GetOSName(). The very portable POSIX::uname()
892 will work too:
893
894 c:\> perl -MPOSIX -we "print join '|', uname"
895 Windows NT|moonru|5.0|Build 2195 (Service Pack 2)|x86
896
897 Also see:
898
899 · The djgpp environment for DOS, http://www.delorie.com/djgpp/ and
900 perldos.
901
902 · The EMX environment for DOS, OS/2, etc. emx@iaehv.nl,
903 http://www.leo.org/pub/comp/os/os2/leo/gnu/emx+gcc/index.html or
904 ftp://hobbes.nmsu.edu/pub/os2/dev/emx/ Also perlos2.
905
906 · Build instructions for Win32 in perlwin32, or under the Cygnus
907 environment in perlcygwin.
908
909 · The "Win32::*" modules in Win32.
910
911 · The ActiveState Pages, http://www.activestate.com/
912
913 · The Cygwin environment for Win32; README.cygwin (installed as
914 perlcygwin), http://www.cygwin.com/
915
916 · The U/WIN environment for Win32,
917 http://www.research.att.com/sw/tools/uwin/
918
919 · Build instructions for OS/2, perlos2
920
921 Mac OS
922 Any module requiring XS compilation is right out for most people,
923 because MacPerl is built using non-free (and non-cheap!) compilers.
924 Some XS modules that can work with MacPerl are built and distributed in
925 binary form on CPAN.
926
927 Directories are specified as:
928
929 volume:folder:file for absolute pathnames
930 volume:folder: for absolute pathnames
931 :folder:file for relative pathnames
932 :folder: for relative pathnames
933 :file for relative pathnames
934 file for relative pathnames
935
936 Files are stored in the directory in alphabetical order. Filenames are
937 limited to 31 characters, and may include any character except for null
938 and ":", which is reserved as the path separator.
939
940 Instead of "flock", see "FSpSetFLock" and "FSpRstFLock" in the
941 Mac::Files module, or "chmod(0444, ...)" and "chmod(0666, ...)".
942
943 In the MacPerl application, you can't run a program from the command
944 line; programs that expect @ARGV to be populated can be edited with
945 something like the following, which brings up a dialog box asking for
946 the command line arguments.
947
948 if (!@ARGV) {
949 @ARGV = split /\s+/, MacPerl::Ask('Arguments?');
950 }
951
952 A MacPerl script saved as a "droplet" will populate @ARGV with the full
953 pathnames of the files dropped onto the script.
954
955 Mac users can run programs under a type of command line interface under
956 MPW (Macintosh Programmer's Workshop, a free development environment
957 from Apple). MacPerl was first introduced as an MPW tool, and MPW can
958 be used like a shell:
959
960 perl myscript.plx some arguments
961
962 ToolServer is another app from Apple that provides access to MPW tools
963 from MPW and the MacPerl app, which allows MacPerl programs to use
964 "system", backticks, and piped "open".
965
966 "Mac OS" is the proper name for the operating system, but the value in
967 $^O is "MacOS". To determine architecture, version, or whether the
968 application or MPW tool version is running, check:
969
970 $is_app = $MacPerl::Version =~ /App/;
971 $is_tool = $MacPerl::Version =~ /MPW/;
972 ($version) = $MacPerl::Version =~ /^(\S+)/;
973 $is_ppc = $MacPerl::Architecture eq 'MacPPC';
974 $is_68k = $MacPerl::Architecture eq 'Mac68K';
975
976 Mac OS X, based on NeXT's OpenStep OS, runs MacPerl natively, under the
977 "Classic" environment. There is no "Carbon" version of MacPerl to run
978 under the primary Mac OS X environment. Mac OS X and its Open Source
979 version, Darwin, both run Unix perl natively.
980
981 Also see:
982
983 · MacPerl Development, http://dev.macperl.org/ .
984
985 · The MacPerl Pages, http://www.macperl.com/ .
986
987 · The MacPerl mailing lists, http://lists.perl.org/ .
988
989 · MPW, ftp://ftp.apple.com/developer/Tool_Chest/Core_Mac_OS_Tools/
990
991 VMS
992 Perl on VMS is discussed in perlvms in the perl distribution.
993
994 The official name of VMS as of this writing is OpenVMS.
995
996 Perl on VMS can accept either VMS- or Unix-style file specifications as
997 in either of the following:
998
999 $ perl -ne "print if /perl_setup/i" SYS$LOGIN:LOGIN.COM
1000 $ perl -ne "print if /perl_setup/i" /sys$login/login.com
1001
1002 but not a mixture of both as in:
1003
1004 $ perl -ne "print if /perl_setup/i" sys$login:/login.com
1005 Can't open sys$login:/login.com: file specification syntax error
1006
1007 Interacting with Perl from the Digital Command Language (DCL) shell
1008 often requires a different set of quotation marks than Unix shells do.
1009 For example:
1010
1011 $ perl -e "print ""Hello, world.\n"""
1012 Hello, world.
1013
1014 There are several ways to wrap your perl scripts in DCL .COM files, if
1015 you are so inclined. For example:
1016
1017 $ write sys$output "Hello from DCL!"
1018 $ if p1 .eqs. ""
1019 $ then perl -x 'f$environment("PROCEDURE")
1020 $ else perl -x - 'p1 'p2 'p3 'p4 'p5 'p6 'p7 'p8
1021 $ deck/dollars="__END__"
1022 #!/usr/bin/perl
1023
1024 print "Hello from Perl!\n";
1025
1026 __END__
1027 $ endif
1028
1029 Do take care with "$ ASSIGN/nolog/user SYS$COMMAND: SYS$INPUT" if your
1030 perl-in-DCL script expects to do things like "$read = <STDIN>;".
1031
1032 The VMS operating system has two filesystems, known as ODS-2 and ODS-5.
1033
1034 For ODS-2, filenames are in the format "name.extension;version". The
1035 maximum length for filenames is 39 characters, and the maximum length
1036 for extensions is also 39 characters. Version is a number from 1 to
1037 32767. Valid characters are "/[A-Z0-9$_-]/".
1038
1039 The ODS-2 filesystem is case-insensitive and does not preserve case.
1040 Perl simulates this by converting all filenames to lowercase
1041 internally.
1042
1043 For ODS-5, filenames may have almost any character in them and can
1044 include Unicode characters. Characters that could be misinterpreted by
1045 the DCL shell or file parsing utilities need to be prefixed with the
1046 "^" character, or replaced with hexadecimal characters prefixed with
1047 the "^" character. Such prefixing is only needed with the pathnames
1048 are in VMS format in applications. Programs that can accept the UNIX
1049 format of pathnames do not need the escape characters. The maximum
1050 length for filenames is 255 characters. The ODS-5 file system can
1051 handle both a case preserved and a case sensitive mode.
1052
1053 ODS-5 is only available on the OpenVMS for 64 bit platforms.
1054
1055 Support for the extended file specifications is being done as optional
1056 settings to preserve backward compatibility with Perl scripts that
1057 assume the previous VMS limitations.
1058
1059 In general routines on VMS that get a UNIX format file specification
1060 should return it in a UNIX format, and when they get a VMS format
1061 specification they should return a VMS format unless they are
1062 documented to do a conversion.
1063
1064 For routines that generate return a file specification, VMS allows
1065 setting if the C library which Perl is built on if it will be returned
1066 in VMS format or in UNIX format.
1067
1068 With the ODS-2 file system, there is not much difference in syntax of
1069 filenames without paths for VMS or UNIX. With the extended character
1070 set available with ODS-5 there can be a significant difference.
1071
1072 Because of this, existing Perl scripts written for VMS were sometimes
1073 treating VMS and UNIX filenames interchangeably. Without the extended
1074 character set enabled, this behavior will mostly be maintained for
1075 backwards compatibility.
1076
1077 When extended characters are enabled with ODS-5, the handling of UNIX
1078 formatted file specifications is to that of a UNIX system.
1079
1080 VMS file specifications without extensions have a trailing dot. An
1081 equivalent UNIX file specification should not show the trailing dot.
1082
1083 The result of all of this, is that for VMS, for portable scripts, you
1084 can not depend on Perl to present the filenames in lowercase, to be
1085 case sensitive, and that the filenames could be returned in either UNIX
1086 or VMS format.
1087
1088 And if a routine returns a file specification, unless it is intended to
1089 convert it, it should return it in the same format as it found it.
1090
1091 "readdir" by default has traditionally returned lowercased filenames.
1092 When the ODS-5 support is enabled, it will return the exact case of the
1093 filename on the disk.
1094
1095 Files without extensions have a trailing period on them, so doing a
1096 "readdir" in the default mode with a file named A.;5 will return a.
1097 when VMS is (though that file could be opened with "open(FH, 'A')").
1098
1099 With support for extended file specifications and if "opendir" was
1100 given a UNIX format directory, a file named A.;5 will return a and
1101 optionally in the exact case on the disk. When "opendir" is given a
1102 VMS format directory, then "readdir" should return a., and again with
1103 the optionally the exact case.
1104
1105 RMS had an eight level limit on directory depths from any rooted
1106 logical (allowing 16 levels overall) prior to VMS 7.2, and even with
1107 versions of VMS on VAX up through 7.3. Hence
1108 "PERL_ROOT:[LIB.2.3.4.5.6.7.8]" is a valid directory specification but
1109 "PERL_ROOT:[LIB.2.3.4.5.6.7.8.9]" is not. Makefile.PL authors might
1110 have to take this into account, but at least they can refer to the
1111 former as "/PERL_ROOT/lib/2/3/4/5/6/7/8/".
1112
1113 Pumpkings and module integrators can easily see whether files with too
1114 many directory levels have snuck into the core by running the following
1115 in the top-level source directory:
1116
1117 $ perl -ne "$_=~s/\s+.*//; print if scalar(split /\//) > 8;" < MANIFEST
1118
1119 The VMS::Filespec module, which gets installed as part of the build
1120 process on VMS, is a pure Perl module that can easily be installed on
1121 non-VMS platforms and can be helpful for conversions to and from RMS
1122 native formats. It is also now the only way that you should check to
1123 see if VMS is in a case sensitive mode.
1124
1125 What "\n" represents depends on the type of file opened. It usually
1126 represents "\012" but it could also be "\015", "\012", "\015\012",
1127 "\000", "\040", or nothing depending on the file organization and
1128 record format. The VMS::Stdio module provides access to the special
1129 fopen() requirements of files with unusual attributes on VMS.
1130
1131 TCP/IP stacks are optional on VMS, so socket routines might not be
1132 implemented. UDP sockets may not be supported.
1133
1134 The TCP/IP library support for all current versions of VMS is
1135 dynamically loaded if present, so even if the routines are configured,
1136 they may return a status indicating that they are not implemented.
1137
1138 The value of $^O on OpenVMS is "VMS". To determine the architecture
1139 that you are running on without resorting to loading all of %Config you
1140 can examine the content of the @INC array like so:
1141
1142 if (grep(/VMS_AXP/, @INC)) {
1143 print "I'm on Alpha!\n";
1144
1145 } elsif (grep(/VMS_VAX/, @INC)) {
1146 print "I'm on VAX!\n";
1147
1148 } elsif (grep(/VMS_IA64/, @INC)) {
1149 print "I'm on IA64!\n";
1150
1151 } else {
1152 print "I'm not so sure about where $^O is...\n";
1153 }
1154
1155 In general, the significant differences should only be if Perl is
1156 running on VMS_VAX or one of the 64 bit OpenVMS platforms.
1157
1158 On VMS, perl determines the UTC offset from the
1159 "SYS$TIMEZONE_DIFFERENTIAL" logical name. Although the VMS epoch began
1160 at 17-NOV-1858 00:00:00.00, calls to "localtime" are adjusted to count
1161 offsets from 01-JAN-1970 00:00:00.00, just like Unix.
1162
1163 Also see:
1164
1165 · README.vms (installed as README_vms), perlvms
1166
1167 · vmsperl list, vmsperl-subscribe@perl.org
1168
1169 · vmsperl on the web, http://www.sidhe.org/vmsperl/index.html
1170
1171 VOS
1172 Perl on VOS is discussed in README.vos in the perl distribution
1173 (installed as perlvos). Perl on VOS can accept either VOS- or Unix-
1174 style file specifications as in either of the following:
1175
1176 $ perl -ne "print if /perl_setup/i" >system>notices
1177 $ perl -ne "print if /perl_setup/i" /system/notices
1178
1179 or even a mixture of both as in:
1180
1181 $ perl -ne "print if /perl_setup/i" >system/notices
1182
1183 Even though VOS allows the slash character to appear in object names,
1184 because the VOS port of Perl interprets it as a pathname delimiting
1185 character, VOS files, directories, or links whose names contain a slash
1186 character cannot be processed. Such files must be renamed before they
1187 can be processed by Perl. Note that VOS limits file names to 32 or
1188 fewer characters, file names cannot start with a "-" character, or
1189 contain any character matching "tr/ !%&'()*+;<>?//"
1190
1191 The value of $^O on VOS is "VOS". To determine the architecture that
1192 you are running on without resorting to loading all of %Config you can
1193 examine the content of the @INC array like so:
1194
1195 if ($^O =~ /VOS/) {
1196 print "I'm on a Stratus box!\n";
1197 } else {
1198 print "I'm not on a Stratus box!\n";
1199 die;
1200 }
1201
1202 Also see:
1203
1204 · README.vos (installed as perlvos)
1205
1206 · The VOS mailing list.
1207
1208 There is no specific mailing list for Perl on VOS. You can post
1209 comments to the comp.sys.stratus newsgroup, or subscribe to the
1210 general Stratus mailing list. Send a letter with "subscribe Info-
1211 Stratus" in the message body to majordomo@list.stratagy.com.
1212
1213 · VOS Perl on the web at
1214 http://ftp.stratus.com/pub/vos/posix/posix.html
1215
1216 EBCDIC Platforms
1217 Recent versions of Perl have been ported to platforms such as OS/400 on
1218 AS/400 minicomputers as well as OS/390, VM/ESA, and BS2000 for S/390
1219 Mainframes. Such computers use EBCDIC character sets internally
1220 (usually Character Code Set ID 0037 for OS/400 and either 1047 or
1221 POSIX-BC for S/390 systems). On the mainframe perl currently works
1222 under the "Unix system services for OS/390" (formerly known as
1223 OpenEdition), VM/ESA OpenEdition, or the BS200 POSIX-BC system (BS2000
1224 is supported in perl 5.6 and greater). See perlos390 for details.
1225 Note that for OS/400 there is also a port of Perl 5.8.1/5.9.0 or later
1226 to the PASE which is ASCII-based (as opposed to ILE which is EBCDIC-
1227 based), see perlos400.
1228
1229 As of R2.5 of USS for OS/390 and Version 2.3 of VM/ESA these Unix sub-
1230 systems do not support the "#!" shebang trick for script invocation.
1231 Hence, on OS/390 and VM/ESA perl scripts can be executed with a header
1232 similar to the following simple script:
1233
1234 : # use perl
1235 eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
1236 if 0;
1237 #!/usr/local/bin/perl # just a comment really
1238
1239 print "Hello from perl!\n";
1240
1241 OS/390 will support the "#!" shebang trick in release 2.8 and beyond.
1242 Calls to "system" and backticks can use POSIX shell syntax on all S/390
1243 systems.
1244
1245 On the AS/400, if PERL5 is in your library list, you may need to wrap
1246 your perl scripts in a CL procedure to invoke them like so:
1247
1248 BEGIN
1249 CALL PGM(PERL5/PERL) PARM('/QOpenSys/hello.pl')
1250 ENDPGM
1251
1252 This will invoke the perl script hello.pl in the root of the QOpenSys
1253 file system. On the AS/400 calls to "system" or backticks must use CL
1254 syntax.
1255
1256 On these platforms, bear in mind that the EBCDIC character set may have
1257 an effect on what happens with some perl functions (such as "chr",
1258 "pack", "print", "printf", "ord", "sort", "sprintf", "unpack"), as well
1259 as bit-fiddling with ASCII constants using operators like "^", "&" and
1260 "|", not to mention dealing with socket interfaces to ASCII computers
1261 (see "Newlines").
1262
1263 Fortunately, most web servers for the mainframe will correctly
1264 translate the "\n" in the following statement to its ASCII equivalent
1265 ("\r" is the same under both Unix and OS/390 & VM/ESA):
1266
1267 print "Content-type: text/html\r\n\r\n";
1268
1269 The values of $^O on some of these platforms includes:
1270
1271 uname $^O $Config{'archname'}
1272 --------------------------------------------
1273 OS/390 os390 os390
1274 OS400 os400 os400
1275 POSIX-BC posix-bc BS2000-posix-bc
1276 VM/ESA vmesa vmesa
1277
1278 Some simple tricks for determining if you are running on an EBCDIC
1279 platform could include any of the following (perhaps all):
1280
1281 if ("\t" eq "\05") { print "EBCDIC may be spoken here!\n"; }
1282
1283 if (ord('A') == 193) { print "EBCDIC may be spoken here!\n"; }
1284
1285 if (chr(169) eq 'z') { print "EBCDIC may be spoken here!\n"; }
1286
1287 One thing you may not want to rely on is the EBCDIC encoding of
1288 punctuation characters since these may differ from code page to code
1289 page (and once your module or script is rumoured to work with EBCDIC,
1290 folks will want it to work with all EBCDIC character sets).
1291
1292 Also see:
1293
1294 · perlos390, README.os390, perlbs2000, README.vmesa, perlebcdic.
1295
1296 · The perl-mvs@perl.org list is for discussion of porting issues as
1297 well as general usage issues for all EBCDIC Perls. Send a message
1298 body of "subscribe perl-mvs" to majordomo@perl.org.
1299
1300 · AS/400 Perl information at http://as400.rochester.ibm.com/ as well
1301 as on CPAN in the ports/ directory.
1302
1303 Acorn RISC OS
1304 Because Acorns use ASCII with newlines ("\n") in text files as "\012"
1305 like Unix, and because Unix filename emulation is turned on by default,
1306 most simple scripts will probably work "out of the box". The native
1307 filesystem is modular, and individual filesystems are free to be case-
1308 sensitive or insensitive, and are usually case-preserving. Some native
1309 filesystems have name length limits, which file and directory names are
1310 silently truncated to fit. Scripts should be aware that the standard
1311 filesystem currently has a name length limit of 10 characters, with up
1312 to 77 items in a directory, but other filesystems may not impose such
1313 limitations.
1314
1315 Native filenames are of the form
1316
1317 Filesystem#Special_Field::DiskName.$.Directory.Directory.File
1318
1319 where
1320
1321 Special_Field is not usually present, but may contain . and $ .
1322 Filesystem =~ m|[A-Za-z0-9_]|
1323 DsicName =~ m|[A-Za-z0-9_/]|
1324 $ represents the root directory
1325 . is the path separator
1326 @ is the current directory (per filesystem but machine global)
1327 ^ is the parent directory
1328 Directory and File =~ m|[^\0- "\.\$\%\&:\@\\^\|\177]+|
1329
1330 The default filename translation is roughly "tr|/.|./|;"
1331
1332 Note that ""ADFS::HardDisk.$.File" ne 'ADFS::HardDisk.$.File'" and that
1333 the second stage of "$" interpolation in regular expressions will fall
1334 foul of the $. if scripts are not careful.
1335
1336 Logical paths specified by system variables containing comma-separated
1337 search lists are also allowed; hence "System:Modules" is a valid
1338 filename, and the filesystem will prefix "Modules" with each section of
1339 "System$Path" until a name is made that points to an object on disk.
1340 Writing to a new file "System:Modules" would be allowed only if
1341 "System$Path" contains a single item list. The filesystem will also
1342 expand system variables in filenames if enclosed in angle brackets, so
1343 "<System$Dir>.Modules" would look for the file
1344 "$ENV{'System$Dir'} . 'Modules'". The obvious implication of this is
1345 that fully qualified filenames can start with "<>" and should be
1346 protected when "open" is used for input.
1347
1348 Because "." was in use as a directory separator and filenames could not
1349 be assumed to be unique after 10 characters, Acorn implemented the C
1350 compiler to strip the trailing ".c" ".h" ".s" and ".o" suffix from
1351 filenames specified in source code and store the respective files in
1352 subdirectories named after the suffix. Hence files are translated:
1353
1354 foo.h h.foo
1355 C:foo.h C:h.foo (logical path variable)
1356 sys/os.h sys.h.os (C compiler groks Unix-speak)
1357 10charname.c c.10charname
1358 10charname.o o.10charname
1359 11charname_.c c.11charname (assuming filesystem truncates at 10)
1360
1361 The Unix emulation library's translation of filenames to native assumes
1362 that this sort of translation is required, and it allows a user-defined
1363 list of known suffixes that it will transpose in this fashion. This
1364 may seem transparent, but consider that with these rules
1365 "foo/bar/baz.h" and "foo/bar/h/baz" both map to "foo.bar.h.baz", and
1366 that "readdir" and "glob" cannot and do not attempt to emulate the
1367 reverse mapping. Other "."'s in filenames are translated to "/".
1368
1369 As implied above, the environment accessed through %ENV is global, and
1370 the convention is that program specific environment variables are of
1371 the form "Program$Name". Each filesystem maintains a current
1372 directory, and the current filesystem's current directory is the global
1373 current directory. Consequently, sociable programs don't change the
1374 current directory but rely on full pathnames, and programs (and
1375 Makefiles) cannot assume that they can spawn a child process which can
1376 change the current directory without affecting its parent (and everyone
1377 else for that matter).
1378
1379 Because native operating system filehandles are global and are
1380 currently allocated down from 255, with 0 being a reserved value, the
1381 Unix emulation library emulates Unix filehandles. Consequently, you
1382 can't rely on passing "STDIN", "STDOUT", or "STDERR" to your children.
1383
1384 The desire of users to express filenames of the form "<Foo$Dir>.Bar" on
1385 the command line unquoted causes problems, too: "``" command output
1386 capture has to perform a guessing game. It assumes that a string
1387 "<[^<>]+\$[^<>]>" is a reference to an environment variable, whereas
1388 anything else involving "<" or ">" is redirection, and generally
1389 manages to be 99% right. Of course, the problem remains that scripts
1390 cannot rely on any Unix tools being available, or that any tools found
1391 have Unix-like command line arguments.
1392
1393 Extensions and XS are, in theory, buildable by anyone using free tools.
1394 In practice, many don't, as users of the Acorn platform are used to
1395 binary distributions. MakeMaker does run, but no available make
1396 currently copes with MakeMaker's makefiles; even if and when this
1397 should be fixed, the lack of a Unix-like shell will cause problems with
1398 makefile rules, especially lines of the form "cd sdbm && make all", and
1399 anything using quoting.
1400
1401 "RISC OS" is the proper name for the operating system, but the value in
1402 $^O is "riscos" (because we don't like shouting).
1403
1404 Other perls
1405 Perl has been ported to many platforms that do not fit into any of the
1406 categories listed above. Some, such as AmigaOS, Atari MiNT, BeOS, HP
1407 MPE/iX, QNX, Plan 9, and VOS, have been well-integrated into the
1408 standard Perl source code kit. You may need to see the ports/
1409 directory on CPAN for information, and possibly binaries, for the likes
1410 of: aos, Atari ST, lynxos, riscos, Novell Netware, Tandem Guardian,
1411 etc. (Yes, we know that some of these OSes may fall under the Unix
1412 category, but we are not a standards body.)
1413
1414 Some approximate operating system names and their $^O values in the
1415 "OTHER" category include:
1416
1417 OS $^O $Config{'archname'}
1418 ------------------------------------------
1419 Amiga DOS amigaos m68k-amigos
1420 BeOS beos
1421 MPE/iX mpeix PA-RISC1.1
1422
1423 See also:
1424
1425 · Amiga, README.amiga (installed as perlamiga).
1426
1427 · Atari, README.mint and Guido Flohr's web page
1428 http://stud.uni-sb.de/~gufl0000/
1429
1430 · Be OS, README.beos
1431
1432 · HP 300 MPE/iX, README.mpeix and Mark Bixby's web page
1433 http://www.bixby.org/mark/perlix.html
1434
1435 · A free perl5-based PERL.NLM for Novell Netware is available in
1436 precompiled binary and source code form from http://www.novell.com/
1437 as well as from CPAN.
1438
1439 · Plan 9, README.plan9
1440
1442 Listed below are functions that are either completely unimplemented or
1443 else have been implemented differently on various platforms. Following
1444 each description will be, in parentheses, a list of platforms that the
1445 description applies to.
1446
1447 The list may well be incomplete, or even wrong in some places. When in
1448 doubt, consult the platform-specific README files in the Perl source
1449 distribution, and any other documentation resources accompanying a
1450 given port.
1451
1452 Be aware, moreover, that even among Unix-ish systems there are
1453 variations.
1454
1455 For many functions, you can also query %Config, exported by default
1456 from the Config module. For example, to check whether the platform has
1457 the "lstat" call, check $Config{d_lstat}. See Config for a full
1458 description of available variables.
1459
1460 Alphabetical Listing of Perl Functions
1461 -X "-r", "-w", and "-x" have a limited meaning only; directories
1462 and applications are executable, and there are no uid/gid
1463 considerations. "-o" is not supported. (Mac OS)
1464
1465 "-w" only inspects the read-only file attribute
1466 (FILE_ATTRIBUTE_READONLY), which determines whether the
1467 directory can be deleted, not whether it can be written to.
1468 Directories always have read and write access unless denied by
1469 discretionary access control lists (DACLs). (Win32)
1470
1471 "-r", "-w", "-x", and "-o" tell whether the file is accessible,
1472 which may not reflect UIC-based file protections. (VMS)
1473
1474 "-s" returns the size of the data fork, not the total size of
1475 data fork plus resource fork. (Mac OS).
1476
1477 "-s" by name on an open file will return the space reserved on
1478 disk, rather than the current extent. "-s" on an open
1479 filehandle returns the current size. (RISC OS)
1480
1481 "-R", "-W", "-X", "-O" are indistinguishable from "-r", "-w",
1482 "-x", "-o". (Mac OS, Win32, VMS, RISC OS)
1483
1484 "-b", "-c", "-k", "-g", "-p", "-u", "-A" are not implemented.
1485 (Mac OS)
1486
1487 "-g", "-k", "-l", "-p", "-u", "-A" are not particularly
1488 meaningful. (Win32, VMS, RISC OS)
1489
1490 "-d" is true if passed a device spec without an explicit
1491 directory. (VMS)
1492
1493 "-T" and "-B" are implemented, but might misclassify Mac text
1494 files with foreign characters; this is the case will all
1495 platforms, but may affect Mac OS often. (Mac OS)
1496
1497 "-x" (or "-X") determine if a file ends in one of the
1498 executable suffixes. "-S" is meaningless. (Win32)
1499
1500 "-x" (or "-X") determine if a file has an executable file type.
1501 (RISC OS)
1502
1503 atan2 Due to issues with various CPUs, math libraries, compilers, and
1504 standards, results for "atan2()" may vary depending on any
1505 combination of the above. Perl attempts to conform to the Open
1506 Group/IEEE standards for the results returned from "atan2()",
1507 but cannot force the issue if the system Perl is run on does
1508 not allow it. (Tru64, HP-UX 10.20)
1509
1510 The current version of the standards for "atan2()" is available
1511 at
1512 <http://www.opengroup.org/onlinepubs/009695399/functions/atan2.html>.
1513
1514 binmode Meaningless. (Mac OS, RISC OS)
1515
1516 Reopens file and restores pointer; if function fails,
1517 underlying filehandle may be closed, or pointer may be in a
1518 different position. (VMS)
1519
1520 The value returned by "tell" may be affected after the call,
1521 and the filehandle may be flushed. (Win32)
1522
1523 chmod Only limited meaning. Disabling/enabling write permission is
1524 mapped to locking/unlocking the file. (Mac OS)
1525
1526 Only good for changing "owner" read-write access, "group", and
1527 "other" bits are meaningless. (Win32)
1528
1529 Only good for changing "owner" and "other" read-write access.
1530 (RISC OS)
1531
1532 Access permissions are mapped onto VOS access-control list
1533 changes. (VOS)
1534
1535 The actual permissions set depend on the value of the "CYGWIN"
1536 in the SYSTEM environment settings. (Cygwin)
1537
1538 chown Not implemented. (Mac OS, Win32, Plan 9, RISC OS)
1539
1540 Does nothing, but won't fail. (Win32)
1541
1542 A little funky, because VOS's notion of ownership is a little
1543 funky (VOS).
1544
1545 chroot Not implemented. (Mac OS, Win32, VMS, Plan 9, RISC OS, VOS,
1546 VM/ESA)
1547
1548 crypt May not be available if library or source was not provided when
1549 building perl. (Win32)
1550
1551 dbmclose
1552 Not implemented. (VMS, Plan 9, VOS)
1553
1554 dbmopen Not implemented. (VMS, Plan 9, VOS)
1555
1556 dump Not useful. (Mac OS, RISC OS)
1557
1558 Not supported. (Cygwin, Win32)
1559
1560 Invokes VMS debugger. (VMS)
1561
1562 exec Not implemented. (Mac OS)
1563
1564 Implemented via Spawn. (VM/ESA)
1565
1566 Does not automatically flush output handles on some platforms.
1567 (SunOS, Solaris, HP-UX)
1568
1569 exit Emulates UNIX exit() (which considers "exit 1" to indicate an
1570 error) by mapping the 1 to SS$_ABORT (44). This behavior may
1571 be overridden with the pragma "use vmsish 'exit'". As with the
1572 CRTL's exit() function, "exit 0" is also mapped to an exit
1573 status of SS$_NORMAL (1); this mapping cannot be overridden.
1574 Any other argument to exit() is used directly as Perl's exit
1575 status. On VMS, unless the future POSIX_EXIT mode is enabled,
1576 the exit code should always be a valid VMS exit code and not a
1577 generic number. When the POSIX_EXIT mode is enabled, a generic
1578 number will be encoded in a method compatible with the C
1579 library _POSIX_EXIT macro so that it can be decoded by other
1580 programs, particularly ones written in C, like the GNV package.
1581 (VMS)
1582
1583 fcntl Not implemented. (Win32) Some functions available based on the
1584 version of VMS. (VMS)
1585
1586 flock Not implemented (Mac OS, VMS, RISC OS, VOS).
1587
1588 Available only on Windows NT (not on Windows 95). (Win32)
1589
1590 fork Not implemented. (Mac OS, AmigaOS, RISC OS, VM/ESA, VMS)
1591
1592 Emulated using multiple interpreters. See perlfork. (Win32)
1593
1594 Does not automatically flush output handles on some platforms.
1595 (SunOS, Solaris, HP-UX)
1596
1597 getlogin
1598 Not implemented. (Mac OS, RISC OS)
1599
1600 getpgrp Not implemented. (Mac OS, Win32, VMS, RISC OS)
1601
1602 getppid Not implemented. (Mac OS, Win32, RISC OS)
1603
1604 getpriority
1605 Not implemented. (Mac OS, Win32, VMS, RISC OS, VOS, VM/ESA)
1606
1607 getpwnam
1608 Not implemented. (Mac OS, Win32)
1609
1610 Not useful. (RISC OS)
1611
1612 getgrnam
1613 Not implemented. (Mac OS, Win32, VMS, RISC OS)
1614
1615 getnetbyname
1616 Not implemented. (Mac OS, Win32, Plan 9)
1617
1618 getpwuid
1619 Not implemented. (Mac OS, Win32)
1620
1621 Not useful. (RISC OS)
1622
1623 getgrgid
1624 Not implemented. (Mac OS, Win32, VMS, RISC OS)
1625
1626 getnetbyaddr
1627 Not implemented. (Mac OS, Win32, Plan 9)
1628
1629 getprotobynumber
1630 Not implemented. (Mac OS)
1631
1632 getservbyport
1633 Not implemented. (Mac OS)
1634
1635 getpwent
1636 Not implemented. (Mac OS, Win32, VM/ESA)
1637
1638 getgrent
1639 Not implemented. (Mac OS, Win32, VMS, VM/ESA)
1640
1641 gethostbyname
1642 "gethostbyname('localhost')" does not work everywhere: you may
1643 have to use "gethostbyname('127.0.0.1')". (Mac OS, Irix 5)
1644
1645 gethostent
1646 Not implemented. (Mac OS, Win32)
1647
1648 getnetent
1649 Not implemented. (Mac OS, Win32, Plan 9)
1650
1651 getprotoent
1652 Not implemented. (Mac OS, Win32, Plan 9)
1653
1654 getservent
1655 Not implemented. (Win32, Plan 9)
1656
1657 sethostent
1658 Not implemented. (Mac OS, Win32, Plan 9, RISC OS)
1659
1660 setnetent
1661 Not implemented. (Mac OS, Win32, Plan 9, RISC OS)
1662
1663 setprotoent
1664 Not implemented. (Mac OS, Win32, Plan 9, RISC OS)
1665
1666 setservent
1667 Not implemented. (Plan 9, Win32, RISC OS)
1668
1669 endpwent
1670 Not implemented. (Mac OS, MPE/iX, VM/ESA, Win32)
1671
1672 endgrent
1673 Not implemented. (Mac OS, MPE/iX, RISC OS, VM/ESA, VMS, Win32)
1674
1675 endhostent
1676 Not implemented. (Mac OS, Win32)
1677
1678 endnetent
1679 Not implemented. (Mac OS, Win32, Plan 9)
1680
1681 endprotoent
1682 Not implemented. (Mac OS, Win32, Plan 9)
1683
1684 endservent
1685 Not implemented. (Plan 9, Win32)
1686
1687 getsockopt SOCKET,LEVEL,OPTNAME
1688 Not implemented. (Plan 9)
1689
1690 glob This operator is implemented via the File::Glob extension on
1691 most platforms. See File::Glob for portability information.
1692
1693 gmtime Same portability caveats as localtime.
1694
1695 ioctl FILEHANDLE,FUNCTION,SCALAR
1696 Not implemented. (VMS)
1697
1698 Available only for socket handles, and it does what the
1699 ioctlsocket() call in the Winsock API does. (Win32)
1700
1701 Available only for socket handles. (RISC OS)
1702
1703 kill "kill(0, LIST)" is implemented for the sake of taint checking;
1704 use with other signals is unimplemented. (Mac OS)
1705
1706 Not implemented, hence not useful for taint checking. (RISC OS)
1707
1708 "kill()" doesn't have the semantics of "raise()", i.e. it
1709 doesn't send a signal to the identified process like it does on
1710 Unix platforms. Instead "kill($sig, $pid)" terminates the
1711 process identified by $pid, and makes it exit immediately with
1712 exit status $sig. As in Unix, if $sig is 0 and the specified
1713 process exists, it returns true without actually terminating
1714 it. (Win32)
1715
1716 "kill(-9, $pid)" will terminate the process specified by $pid
1717 and recursively all child processes owned by it. This is
1718 different from the Unix semantics, where the signal will be
1719 delivered to all processes in the same process group as the
1720 process specified by $pid. (Win32)
1721
1722 Is not supported for process identification number of 0 or
1723 negative numbers. (VMS)
1724
1725 link Not implemented. (Mac OS, MPE/iX, RISC OS)
1726
1727 Link count not updated because hard links are not quite that
1728 hard (They are sort of half-way between hard and soft links).
1729 (AmigaOS)
1730
1731 Hard links are implemented on Win32 under NTFS only. They are
1732 natively supported on Windows 2000 and later. On Windows NT
1733 they are implemented using the Windows POSIX subsystem support
1734 and the Perl process will need Administrator or Backup Operator
1735 privileges to create hard links.
1736
1737 Available on 64 bit OpenVMS 8.2 and later. (VMS)
1738
1739 localtime
1740 Because Perl currently relies on the native standard C
1741 localtime() function, it is only safe to use times between 0
1742 and (2**31)-1. Times outside this range may result in
1743 unexpected behavior depending on your operating system's
1744 implementation of localtime().
1745
1746 lstat Not implemented. (RISC OS)
1747
1748 Return values (especially for device and inode) may be bogus.
1749 (Win32)
1750
1751 msgctl
1752 msgget
1753 msgsnd
1754 msgrcv Not implemented. (Mac OS, Win32, VMS, Plan 9, RISC OS, VOS)
1755
1756 open The "|" variants are supported only if ToolServer is installed.
1757 (Mac OS)
1758
1759 open to "|-" and "-|" are unsupported. (Mac OS, Win32, RISC OS)
1760
1761 Opening a process does not automatically flush output handles
1762 on some platforms. (SunOS, Solaris, HP-UX)
1763
1764 pipe Very limited functionality. (MiNT)
1765
1766 readlink
1767 Not implemented. (Win32, VMS, RISC OS)
1768
1769 rename Can't move directories between directories on different logical
1770 volumes. (Win32)
1771
1772 select Only implemented on sockets. (Win32, VMS)
1773
1774 Only reliable on sockets. (RISC OS)
1775
1776 Note that the "select FILEHANDLE" form is generally portable.
1777
1778 semctl
1779 semget
1780 semop Not implemented. (Mac OS, Win32, VMS, RISC OS, VOS)
1781
1782 setgrent
1783 Not implemented. (Mac OS, MPE/iX, VMS, Win32, RISC OS, VOS)
1784
1785 setpgrp Not implemented. (Mac OS, Win32, VMS, RISC OS, VOS)
1786
1787 setpriority
1788 Not implemented. (Mac OS, Win32, VMS, RISC OS, VOS)
1789
1790 setpwent
1791 Not implemented. (Mac OS, MPE/iX, Win32, RISC OS, VOS)
1792
1793 setsockopt
1794 Not implemented. (Plan 9)
1795
1796 shmctl
1797 shmget
1798 shmread
1799 shmwrite
1800 Not implemented. (Mac OS, Win32, VMS, RISC OS, VOS)
1801
1802 sockatmark
1803 A relatively recent addition to socket functions, may not be
1804 implemented even in UNIX platforms.
1805
1806 socketpair
1807 Not implemented. (RISC OS, VOS, VM/ESA)
1808
1809 Available on 64 bit OpenVMS 8.2 and later. (VMS)
1810
1811 stat Platforms that do not have rdev, blksize, or blocks will return
1812 these as '', so numeric comparison or manipulation of these
1813 fields may cause 'not numeric' warnings.
1814
1815 mtime and atime are the same thing, and ctime is creation time
1816 instead of inode change time. (Mac OS).
1817
1818 ctime not supported on UFS (Mac OS X).
1819
1820 ctime is creation time instead of inode change time (Win32).
1821
1822 device and inode are not meaningful. (Win32)
1823
1824 device and inode are not necessarily reliable. (VMS)
1825
1826 mtime, atime and ctime all return the last modification time.
1827 Device and inode are not necessarily reliable. (RISC OS)
1828
1829 dev, rdev, blksize, and blocks are not available. inode is not
1830 meaningful and will differ between stat calls on the same file.
1831 (os2)
1832
1833 some versions of cygwin when doing a stat("foo") and if not
1834 finding it may then attempt to stat("foo.exe") (Cygwin)
1835
1836 On Win32 stat() needs to open the file to determine the link
1837 count and update attributes that may have been changed through
1838 hard links. Setting ${^WIN32_SLOPPY_STAT} to a true value
1839 speeds up stat() by not performing this operation. (Win32)
1840
1841 symlink Not implemented. (Win32, RISC OS)
1842
1843 Implemented on 64 bit VMS 8.3. VMS requires the symbolic link
1844 to be in Unix syntax if it is intended to resolve to a valid
1845 path.
1846
1847 syscall Not implemented. (Mac OS, Win32, VMS, RISC OS, VOS, VM/ESA)
1848
1849 sysopen The traditional "0", "1", and "2" MODEs are implemented with
1850 different numeric values on some systems. The flags exported
1851 by "Fcntl" (O_RDONLY, O_WRONLY, O_RDWR) should work everywhere
1852 though. (Mac OS, OS/390, VM/ESA)
1853
1854 system Only implemented if ToolServer is installed. (Mac OS)
1855
1856 As an optimization, may not call the command shell specified in
1857 $ENV{PERL5SHELL}. "system(1, @args)" spawns an external
1858 process and immediately returns its process designator, without
1859 waiting for it to terminate. Return value may be used
1860 subsequently in "wait" or "waitpid". Failure to spawn() a
1861 subprocess is indicated by setting $? to "255 << 8". $? is set
1862 in a way compatible with Unix (i.e. the exitstatus of the
1863 subprocess is obtained by "$? >> 8", as described in the
1864 documentation). (Win32)
1865
1866 There is no shell to process metacharacters, and the native
1867 standard is to pass a command line terminated by "\n" "\r" or
1868 "\0" to the spawned program. Redirection such as "> foo" is
1869 performed (if at all) by the run time library of the spawned
1870 program. "system" list will call the Unix emulation library's
1871 "exec" emulation, which attempts to provide emulation of the
1872 stdin, stdout, stderr in force in the parent, providing the
1873 child program uses a compatible version of the emulation
1874 library. scalar will call the native command line direct and
1875 no such emulation of a child Unix program will exists. Mileage
1876 will vary. (RISC OS)
1877
1878 Far from being POSIX compliant. Because there may be no
1879 underlying /bin/sh tries to work around the problem by forking
1880 and execing the first token in its argument string. Handles
1881 basic redirection ("<" or ">") on its own behalf. (MiNT)
1882
1883 Does not automatically flush output handles on some platforms.
1884 (SunOS, Solaris, HP-UX)
1885
1886 The return value is POSIX-like (shifted up by 8 bits), which
1887 only allows room for a made-up value derived from the severity
1888 bits of the native 32-bit condition code (unless overridden by
1889 "use vmsish 'status'"). If the native condition code is one
1890 that has a POSIX value encoded, the POSIX value will be decoded
1891 to extract the expected exit value. For more details see "$?"
1892 in perlvms. (VMS)
1893
1894 times Only the first entry returned is nonzero. (Mac OS)
1895
1896 "cumulative" times will be bogus. On anything other than
1897 Windows NT or Windows 2000, "system" time will be bogus, and
1898 "user" time is actually the time returned by the clock()
1899 function in the C runtime library. (Win32)
1900
1901 Not useful. (RISC OS)
1902
1903 truncate
1904 Not implemented. (Older versions of VMS)
1905
1906 Truncation to same-or-shorter lengths only. (VOS)
1907
1908 If a FILEHANDLE is supplied, it must be writable and opened in
1909 append mode (i.e., use "open(FH, '>>filename')" or
1910 "sysopen(FH,...,O_APPEND|O_RDWR)". If a filename is supplied,
1911 it should not be held open elsewhere. (Win32)
1912
1913 umask Returns undef where unavailable, as of version 5.005.
1914
1915 "umask" works but the correct permissions are set only when the
1916 file is finally closed. (AmigaOS)
1917
1918 utime Only the modification time is updated. (BeOS, Mac OS, VMS,
1919 RISC OS)
1920
1921 May not behave as expected. Behavior depends on the C runtime
1922 library's implementation of utime(), and the filesystem being
1923 used. The FAT filesystem typically does not support an "access
1924 time" field, and it may limit timestamps to a granularity of
1925 two seconds. (Win32)
1926
1927 wait
1928 waitpid Not implemented. (Mac OS)
1929
1930 Can only be applied to process handles returned for processes
1931 spawned using "system(1, ...)" or pseudo processes created with
1932 "fork()". (Win32)
1933
1934 Not useful. (RISC OS)
1935
1937 As of July 2002 (the Perl release 5.8.0), the following platforms are
1938 able to build Perl from the standard source code distribution available
1939 at http://www.cpan.org/src/index.html
1940
1941 AIX
1942 BeOS
1943 BSD/OS (BSDi)
1944 Cygwin
1945 DG/UX
1946 DOS DJGPP 1)
1947 DYNIX/ptx
1948 EPOC R5
1949 FreeBSD
1950 HI-UXMPP (Hitachi) (5.8.0 worked but we didn't know it)
1951 HP-UX
1952 IRIX
1953 Linux
1954 Mac OS Classic
1955 Mac OS X (Darwin)
1956 MPE/iX
1957 NetBSD
1958 NetWare
1959 NonStop-UX
1960 ReliantUNIX (formerly SINIX)
1961 OpenBSD
1962 OpenVMS (formerly VMS)
1963 Open UNIX (Unixware) (since Perl 5.8.1/5.9.0)
1964 OS/2
1965 OS/400 (using the PASE) (since Perl 5.8.1/5.9.0)
1966 PowerUX
1967 POSIX-BC (formerly BS2000)
1968 QNX
1969 Solaris
1970 SunOS 4
1971 SUPER-UX (NEC)
1972 Tru64 UNIX (formerly DEC OSF/1, Digital UNIX)
1973 UNICOS
1974 UNICOS/mk
1975 UTS
1976 VOS
1977 Win95/98/ME/2K/XP 2)
1978 WinCE
1979 z/OS (formerly OS/390)
1980 VM/ESA
1981
1982 1) in DOS mode either the DOS or OS/2 ports can be used
1983 2) compilers: Borland, MinGW (GCC), VC6
1984
1985 The following platforms worked with the previous releases (5.6 and
1986 5.7), but we did not manage either to fix or to test these in time for
1987 the 5.8.0 release. There is a very good chance that many of these will
1988 work fine with the 5.8.0.
1989
1990 BSD/OS
1991 DomainOS
1992 Hurd
1993 LynxOS
1994 MachTen
1995 PowerMAX
1996 SCO SV
1997 SVR4
1998 Unixware
1999 Windows 3.1
2000
2001 Known to be broken for 5.8.0 (but 5.6.1 and 5.7.2 can be used):
2002
2003 AmigaOS
2004
2005 The following platforms have been known to build Perl from source in
2006 the past (5.005_03 and earlier), but we haven't been able to verify
2007 their status for the current release, either because the
2008 hardware/software platforms are rare or because we don't have an active
2009 champion on these platforms--or both. They used to work, though, so go
2010 ahead and try compiling them, and let perlbug@perl.org of any trouble.
2011
2012 3b1
2013 A/UX
2014 ConvexOS
2015 CX/UX
2016 DC/OSx
2017 DDE SMES
2018 DOS EMX
2019 Dynix
2020 EP/IX
2021 ESIX
2022 FPS
2023 GENIX
2024 Greenhills
2025 ISC
2026 MachTen 68k
2027 MiNT
2028 MPC
2029 NEWS-OS
2030 NextSTEP
2031 OpenSTEP
2032 Opus
2033 Plan 9
2034 RISC/os
2035 SCO ODT/OSR
2036 Stellar
2037 SVR2
2038 TI1500
2039 TitanOS
2040 Ultrix
2041 Unisys Dynix
2042
2043 The following platforms have their own source code distributions and
2044 binaries available via http://www.cpan.org/ports/
2045
2046 Perl release
2047
2048 OS/400 (ILE) 5.005_02
2049 Tandem Guardian 5.004
2050
2051 The following platforms have only binaries available via
2052 http://www.cpan.org/ports/index.html :
2053
2054 Perl release
2055
2056 Acorn RISCOS 5.005_02
2057 AOS 5.002
2058 LynxOS 5.004_02
2059
2060 Although we do suggest that you always build your own Perl from the
2061 source code, both for maximal configurability and for security, in case
2062 you are in a hurry you can check http://www.cpan.org/ports/index.html
2063 for binary distributions.
2064
2066 perlaix, perlamiga, perlapollo, perlbeos, perlbs2000, perlce,
2067 perlcygwin, perldgux, perldos, perlepoc, perlebcdic, perlfreebsd,
2068 perlhurd, perlhpux, perlirix, perlmachten, perlmacos, perlmacosx,
2069 perlmint, perlmpeix, perlnetware, perlos2, perlos390, perlos400,
2070 perlplan9, perlqnx, perlsolaris, perltru64, perlunicode, perlvmesa,
2071 perlvms, perlvos, perlwin32, and Win32.
2072
2074 Abigail <abigail@foad.org>, Charles Bailey <bailey@newman.upenn.edu>,
2075 Graham Barr <gbarr@pobox.com>, Tom Christiansen <tchrist@perl.com>,
2076 Nicholas Clark <nick@ccl4.org>, Thomas Dorner <Thomas.Dorner@start.de>,
2077 Andy Dougherty <doughera@lafayette.edu>, Dominic Dunlop
2078 <domo@computer.org>, Neale Ferguson <neale@vma.tabnsw.com.au>, David J.
2079 Fiander <davidf@mks.com>, Paul Green <Paul.Green@stratus.com>, M.J.T.
2080 Guy <mjtg@cam.ac.uk>, Jarkko Hietaniemi <jhi@iki.fi>, Luther Huffman
2081 <lutherh@stratcom.com>, Nick Ing-Simmons <nick@ing-simmons.net>,
2082 Andreas J. Koenig <a.koenig@mind.de>, Markus Laker
2083 <mlaker@contax.co.uk>, Andrew M. Langmead <aml@world.std.com>, Larry
2084 Moore <ljmoore@freespace.net>, Paul Moore
2085 <Paul.Moore@uk.origin-it.com>, Chris Nandor <pudge@pobox.com>, Matthias
2086 Neeracher <neeracher@mac.com>, Philip Newton <pne@cpan.org>, Gary Ng
2087 <71564.1743@CompuServe.COM>, Tom Phoenix <rootbeer@teleport.com>, Andre
2088 Pirard <A.Pirard@ulg.ac.be>, Peter Prymmer <pvhp@forte.com>, Hugo van
2089 der Sanden <hv@crypt0.demon.co.uk>, Gurusamy Sarathy
2090 <gsar@activestate.com>, Paul J. Schinder <schinder@pobox.com>, Michael
2091 G Schwern <schwern@pobox.com>, Dan Sugalski <dan@sidhe.org>, Nathan
2092 Torkington <gnat@frii.com>. John Malmberg <wb8tyw@qsl.net>
2093
2094
2095
2096perl v5.10.1 2009-05-14 PERLPORT(1)