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, VMS, etc.),
60 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, perl uses the ":crlf" layer that
89 translates it to (or from) "\015\012", depending on whether you're
90 reading or writing. Unix does the same thing on ttys in canonical mode.
91 "\015\012" is commonly 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 9 and earlier used ":" 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 my $file = catfile(curdir(), 'temp', 'file.txt');
296 # on Unix and Win32, './temp/file.txt'
297 # on Mac OS Classic, ':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 my $fh, '<', $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 my $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 my $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 that for
517 things such as DHCP and NAT, the hostname you get back might not be
518 very useful.
519
520 All the above "don't":s may look daunting, and they are, but the key is
521 to degrade gracefully if one cannot reach the particular network
522 service one wants. Croaking or hanging do not look very professional.
523
524 Interprocess Communication (IPC)
525 In general, don't directly access the system in code meant to be
526 portable. That means, no "system", "exec", "fork", "pipe", "``",
527 "qx//", "open" with a "|", nor any of the other things that makes being
528 a perl hacker worth being.
529
530 Commands that launch external processes are generally supported on most
531 platforms (though many of them do not support any type of forking).
532 The problem with using them arises from what you invoke them on.
533 External tools are often named differently on different platforms, may
534 not be available in the same location, might accept different
535 arguments, can behave differently, and often present their results in a
536 platform-dependent way. Thus, you should seldom depend on them to
537 produce consistent results. (Then again, if you're calling netstat -a,
538 you probably don't expect it to run on both Unix and CP/M.)
539
540 One especially common bit of Perl code is opening a pipe to sendmail:
541
542 open(MAIL, '|/usr/lib/sendmail -t')
543 or die "cannot fork sendmail: $!";
544
545 This is fine for systems programming when sendmail is known to be
546 available. But it is not fine for many non-Unix systems, and even some
547 Unix systems that may not have sendmail installed. If a portable
548 solution is needed, see the various distributions on CPAN that deal
549 with it. Mail::Mailer and Mail::Send in the MailTools distribution are
550 commonly used, and provide several mailing methods, including mail,
551 sendmail, and direct SMTP (via Net::SMTP) if a mail transfer agent is
552 not available. Mail::Sendmail is a standalone module that provides
553 simple, platform-independent mailing.
554
555 The Unix System V IPC ("msg*(), sem*(), shm*()") is not available even
556 on all Unix platforms.
557
558 Do not use either the bare result of "pack("N", 10, 20, 30, 40)" or
559 bare v-strings (such as "v10.20.30.40") to represent IPv4 addresses:
560 both forms just pack the four bytes into network order. That this
561 would be equal to the C language "in_addr" struct (which is what the
562 socket code internally uses) is not guaranteed. To be portable use the
563 routines of the Socket extension, such as "inet_aton()", "inet_ntoa()",
564 and "sockaddr_in()".
565
566 The rule of thumb for portable code is: Do it all in portable Perl, or
567 use a module (that may internally implement it with platform-specific
568 code, but expose a common interface).
569
570 External Subroutines (XS)
571 XS code can usually be made to work with any platform, but dependent
572 libraries, header files, etc., might not be readily available or
573 portable, or the XS code itself might be platform-specific, just as
574 Perl code might be. If the libraries and headers are portable, then it
575 is normally reasonable to make sure the XS code is portable, too.
576
577 A different type of portability issue arises when writing XS code:
578 availability of a C compiler on the end-user's system. C brings with
579 it its own portability issues, and writing XS code will expose you to
580 some of those. Writing purely in Perl is an easier way to achieve
581 portability.
582
583 Standard Modules
584 In general, the standard modules work across platforms. Notable
585 exceptions are the CPAN module (which currently makes connections to
586 external programs that may not be available), platform-specific modules
587 (like ExtUtils::MM_VMS), and DBM modules.
588
589 There is no one DBM module available on all platforms. SDBM_File and
590 the others are generally available on all Unix and DOSish ports, but
591 not in MacPerl, where only NBDM_File and DB_File are available.
592
593 The good news is that at least some DBM module should be available, and
594 AnyDBM_File will use whichever module it can find. Of course, then the
595 code needs to be fairly strict, dropping to the greatest common factor
596 (e.g., not exceeding 1K for each record), so that it will work with any
597 DBM module. See AnyDBM_File for more details.
598
599 Time and Date
600 The system's notion of time of day and calendar date is controlled in
601 widely different ways. Don't assume the timezone is stored in
602 $ENV{TZ}, and even if it is, don't assume that you can control the
603 timezone through that variable. Don't assume anything about the three-
604 letter timezone abbreviations (for example that MST would be the
605 Mountain Standard Time, it's been known to stand for Moscow Standard
606 Time). If you need to use timezones, express them in some unambiguous
607 format like the exact number of minutes offset from UTC, or the POSIX
608 timezone format.
609
610 Don't assume that the epoch starts at 00:00:00, January 1, 1970,
611 because that is OS- and implementation-specific. It is better to store
612 a date in an unambiguous representation. The ISO 8601 standard defines
613 YYYY-MM-DD as the date format, or YYYY-MM-DDTHH:MM:SS (that's a literal
614 "T" separating the date from the time). Please do use the ISO 8601
615 instead of making us guess what date 02/03/04 might be. ISO 8601 even
616 sorts nicely as-is. A text representation (like "1987-12-18") can be
617 easily converted into an OS-specific value using a module like
618 Date::Parse. An array of values, such as those returned by
619 "localtime", can be converted to an OS-specific representation using
620 Time::Local.
621
622 When calculating specific times, such as for tests in time or date
623 modules, it may be appropriate to calculate an offset for the epoch.
624
625 require Time::Local;
626 my $offset = Time::Local::timegm(0, 0, 0, 1, 0, 70);
627
628 The value for $offset in Unix will be 0, but in Mac OS Classic will be
629 some large number. $offset can then be added to a Unix time value to
630 get what should be the proper value on any system.
631
632 Character sets and character encoding
633 Assume very little about character sets.
634
635 Assume nothing about numerical values ("ord", "chr") of characters. Do
636 not use explicit code point ranges (like \xHH-\xHH); use for example
637 symbolic character classes like "[:print:]".
638
639 Do not assume that the alphabetic characters are encoded contiguously
640 (in the numeric sense). There may be gaps.
641
642 Do not assume anything about the ordering of the characters. The
643 lowercase letters may come before or after the uppercase letters; the
644 lowercase and uppercase may be interlaced so that both "a" and "A" come
645 before "b"; the accented and other international characters may be
646 interlaced so that ae comes before "b".
647
648 Internationalisation
649 If you may assume POSIX (a rather large assumption), you may read more
650 about the POSIX locale system from perllocale. The locale system at
651 least attempts to make things a little bit more portable, or at least
652 more convenient and native-friendly for non-English users. The system
653 affects character sets and encoding, and date and time
654 formatting--amongst other things.
655
656 If you really want to be international, you should consider Unicode.
657 See perluniintro and perlunicode for more information.
658
659 If you want to use non-ASCII bytes (outside the bytes 0x00..0x7f) in
660 the "source code" of your code, to be portable you have to be explicit
661 about what bytes they are. Someone might for example be using your
662 code under a UTF-8 locale, in which case random native bytes might be
663 illegal ("Malformed UTF-8 ...") This means that for example embedding
664 ISO 8859-1 bytes beyond 0x7f into your strings might cause trouble
665 later. If the bytes are native 8-bit bytes, you can use the "bytes"
666 pragma. If the bytes are in a string (regular expression being a
667 curious string), you can often also use the "\xHH" notation instead of
668 embedding the bytes as-is. (If you want to write your code in UTF-8,
669 you can use the "utf8".) The "bytes" and "utf8" pragmata are available
670 since Perl 5.6.0.
671
672 System Resources
673 If your code is destined for systems with severely constrained (or
674 missing!) virtual memory systems then you want to be especially mindful
675 of avoiding wasteful constructs such as:
676
677 my @lines = <$very_large_file>; # bad
678
679 while (<$fh>) {$file .= $_} # sometimes bad
680 my $file = join('', <$fh>); # better
681
682 The last two constructs may appear unintuitive to most people. The
683 first repeatedly grows a string, whereas the second allocates a large
684 chunk of memory in one go. On some systems, the second is more
685 efficient that the first.
686
687 Security
688 Most multi-user platforms provide basic levels of security, usually
689 implemented at the filesystem level. Some, however, unfortunately do
690 not. Thus the notion of user id, or "home" directory, or even the
691 state of being logged-in, may be unrecognizable on many platforms. If
692 you write programs that are security-conscious, it is usually best to
693 know what type of system you will be running under so that you can
694 write code explicitly for that platform (or class of platforms).
695
696 Don't assume the Unix filesystem access semantics: the operating system
697 or the filesystem may be using some ACL systems, which are richer
698 languages than the usual rwx. Even if the rwx exist, their semantics
699 might be different.
700
701 (From security viewpoint testing for permissions before attempting to
702 do something is silly anyway: if one tries this, there is potential for
703 race conditions. Someone or something might change the permissions
704 between the permissions check and the actual operation. Just try the
705 operation.)
706
707 Don't assume the Unix user and group semantics: especially, don't
708 expect the $< and $> (or the $( and $)) to work for switching
709 identities (or memberships).
710
711 Don't assume set-uid and set-gid semantics. (And even if you do, think
712 twice: set-uid and set-gid are a known can of security worms.)
713
714 Style
715 For those times when it is necessary to have platform-specific code,
716 consider keeping the platform-specific code in one place, making
717 porting to other platforms easier. Use the Config module and the
718 special variable $^O to differentiate platforms, as described in
719 "PLATFORMS".
720
721 Be careful in the tests you supply with your module or programs.
722 Module code may be fully portable, but its tests might not be. This
723 often happens when tests spawn off other processes or call external
724 programs to aid in the testing, or when (as noted above) the tests
725 assume certain things about the filesystem and paths. Be careful not
726 to depend on a specific output style for errors, such as when checking
727 $! after a failed system call. Using $! for anything else than
728 displaying it as output is doubtful (though see the Errno module for
729 testing reasonably portably for error value). Some platforms expect a
730 certain output format, and Perl on those platforms may have been
731 adjusted accordingly. Most specifically, don't anchor a regex when
732 testing an error value.
733
735 Modules uploaded to CPAN are tested by a variety of volunteers on
736 different platforms. These CPAN testers are notified by mail of each
737 new upload, and reply to the list with PASS, FAIL, NA (not applicable
738 to this platform), or UNKNOWN (unknown), along with any relevant
739 notations.
740
741 The purpose of the testing is twofold: one, to help developers fix any
742 problems in their code that crop up because of lack of testing on other
743 platforms; two, to provide users with information about whether a given
744 module works on a given platform.
745
746 Also see:
747
748 · Mailing list: cpan-testers-discuss@perl.org
749
750 · Testing results: <http://www.cpantesters.org/>
751
753 As of version 5.002, Perl is built with a $^O variable that indicates
754 the operating system it was built on. This was implemented to help
755 speed up code that would otherwise have to "use Config" and use the
756 value of $Config{osname}. Of course, to get more detailed information
757 about the system, looking into %Config is certainly recommended.
758
759 %Config cannot always be trusted, however, because it was built at
760 compile time. If perl was built in one place, then transferred
761 elsewhere, some values may be wrong. The values may even have been
762 edited after the fact.
763
764 Unix
765 Perl works on a bewildering variety of Unix and Unix-like platforms
766 (see e.g. most of the files in the hints/ directory in the source code
767 kit). On most of these systems, the value of $^O (hence
768 $Config{'osname'}, too) is determined either by lowercasing and
769 stripping punctuation from the first field of the string returned by
770 typing "uname -a" (or a similar command) at the shell prompt or by
771 testing the file system for the presence of uniquely named files such
772 as a kernel or header file. Here, for example, are a few of the more
773 popular Unix flavors:
774
775 uname $^O $Config{'archname'}
776 --------------------------------------------
777 AIX aix aix
778 BSD/OS bsdos i386-bsdos
779 Darwin darwin darwin
780 dgux dgux AViiON-dgux
781 DYNIX/ptx dynixptx i386-dynixptx
782 FreeBSD freebsd freebsd-i386
783 Haiku haiku BePC-haiku
784 Linux linux arm-linux
785 Linux linux i386-linux
786 Linux linux i586-linux
787 Linux linux ppc-linux
788 HP-UX hpux PA-RISC1.1
789 IRIX irix irix
790 Mac OS X darwin darwin
791 NeXT 3 next next-fat
792 NeXT 4 next OPENSTEP-Mach
793 openbsd openbsd i386-openbsd
794 OSF1 dec_osf alpha-dec_osf
795 reliantunix-n svr4 RM400-svr4
796 SCO_SV sco_sv i386-sco_sv
797 SINIX-N svr4 RM400-svr4
798 sn4609 unicos CRAY_C90-unicos
799 sn6521 unicosmk t3e-unicosmk
800 sn9617 unicos CRAY_J90-unicos
801 SunOS solaris sun4-solaris
802 SunOS solaris i86pc-solaris
803 SunOS4 sunos sun4-sunos
804
805 Because the value of $Config{archname} may depend on the hardware
806 architecture, it can vary more than the value of $^O.
807
808 DOS and Derivatives
809 Perl has long been ported to Intel-style microcomputers running under
810 systems like PC-DOS, MS-DOS, OS/2, and most Windows platforms you can
811 bring yourself to mention (except for Windows CE, if you count that).
812 Users familiar with COMMAND.COM or CMD.EXE style shells should be aware
813 that each of these file specifications may have subtle differences:
814
815 my $filespec0 = "c:/foo/bar/file.txt";
816 my $filespec1 = "c:\\foo\\bar\\file.txt";
817 my $filespec2 = 'c:\foo\bar\file.txt';
818 my $filespec3 = 'c:\\foo\\bar\\file.txt';
819
820 System calls accept either "/" or "\" as the path separator. However,
821 many command-line utilities of DOS vintage treat "/" as the option
822 prefix, so may get confused by filenames containing "/". Aside from
823 calling any external programs, "/" will work just fine, and probably
824 better, as it is more consistent with popular usage, and avoids the
825 problem of remembering what to backwhack and what not to.
826
827 The DOS FAT filesystem can accommodate only "8.3" style filenames.
828 Under the "case-insensitive, but case-preserving" HPFS (OS/2) and NTFS
829 (NT) filesystems you may have to be careful about case returned with
830 functions like "readdir" or used with functions like "open" or
831 "opendir".
832
833 DOS also treats several filenames as special, such as AUX, PRN, NUL,
834 CON, COM1, LPT1, LPT2, etc. Unfortunately, sometimes these filenames
835 won't even work if you include an explicit directory prefix. It is
836 best to avoid such filenames, if you want your code to be portable to
837 DOS and its derivatives. It's hard to know what these all are,
838 unfortunately.
839
840 Users of these operating systems may also wish to make use of scripts
841 such as pl2bat.bat or pl2cmd to put wrappers around your scripts.
842
843 Newline ("\n") is translated as "\015\012" by STDIO when reading from
844 and writing to files (see "Newlines"). "binmode(FILEHANDLE)" will keep
845 "\n" translated as "\012" for that filehandle. Since it is a no-op on
846 other systems, "binmode" should be used for cross-platform code that
847 deals with binary data. That's assuming you realize in advance that
848 your data is in binary. General-purpose programs should often assume
849 nothing about their data.
850
851 The $^O variable and the $Config{archname} values for various DOSish
852 perls are as follows:
853
854 OS $^O $Config{archname} ID Version
855 --------------------------------------------------------
856 MS-DOS dos ?
857 PC-DOS dos ?
858 OS/2 os2 ?
859 Windows 3.1 ? ? 0 3 01
860 Windows 95 MSWin32 MSWin32-x86 1 4 00
861 Windows 98 MSWin32 MSWin32-x86 1 4 10
862 Windows ME MSWin32 MSWin32-x86 1 ?
863 Windows NT MSWin32 MSWin32-x86 2 4 xx
864 Windows NT MSWin32 MSWin32-ALPHA 2 4 xx
865 Windows NT MSWin32 MSWin32-ppc 2 4 xx
866 Windows 2000 MSWin32 MSWin32-x86 2 5 00
867 Windows XP MSWin32 MSWin32-x86 2 5 01
868 Windows 2003 MSWin32 MSWin32-x86 2 5 02
869 Windows Vista MSWin32 MSWin32-x86 2 6 00
870 Windows 7 MSWin32 MSWin32-x86 2 6 01
871 Windows 7 MSWin32 MSWin32-x64 2 6 01
872 Windows 2008 MSWin32 MSWin32-x86 2 6 01
873 Windows 2008 MSWin32 MSWin32-x64 2 6 01
874 Windows CE MSWin32 ? 3
875 Cygwin cygwin cygwin
876
877 The various MSWin32 Perl's can distinguish the OS they are running on
878 via the value of the fifth element of the list returned from
879 Win32::GetOSVersion(). For example:
880
881 if ($^O eq 'MSWin32') {
882 my @os_version_info = Win32::GetOSVersion();
883 print +('3.1','95','NT')[$os_version_info[4]],"\n";
884 }
885
886 There are also Win32::IsWinNT() and Win32::IsWin95(), try "perldoc
887 Win32", and as of libwin32 0.19 (not part of the core Perl
888 distribution) Win32::GetOSName(). The very portable POSIX::uname()
889 will work too:
890
891 c:\> perl -MPOSIX -we "print join '|', uname"
892 Windows NT|moonru|5.0|Build 2195 (Service Pack 2)|x86
893
894 Also see:
895
896 · The djgpp environment for DOS, <http://www.delorie.com/djgpp/> and
897 perldos.
898
899 · The EMX environment for DOS, OS/2, etc. emx@iaehv.nl,
900 <ftp://hobbes.nmsu.edu/pub/os2/dev/emx/> Also perlos2.
901
902 · Build instructions for Win32 in perlwin32, or under the Cygnus
903 environment in perlcygwin.
904
905 · The "Win32::*" modules in Win32.
906
907 · The ActiveState Pages, <http://www.activestate.com/>
908
909 · The Cygwin environment for Win32; README.cygwin (installed as
910 perlcygwin), <http://www.cygwin.com/>
911
912 · The U/WIN environment for Win32,
913 <http://www.research.att.com/sw/tools/uwin/>
914
915 · Build instructions for OS/2, perlos2
916
917 VMS
918 Perl on VMS is discussed in perlvms in the perl distribution.
919
920 The official name of VMS as of this writing is OpenVMS.
921
922 Perl on VMS can accept either VMS- or Unix-style file specifications as
923 in either of the following:
924
925 $ perl -ne "print if /perl_setup/i" SYS$LOGIN:LOGIN.COM
926 $ perl -ne "print if /perl_setup/i" /sys$login/login.com
927
928 but not a mixture of both as in:
929
930 $ perl -ne "print if /perl_setup/i" sys$login:/login.com
931 Can't open sys$login:/login.com: file specification syntax error
932
933 Interacting with Perl from the Digital Command Language (DCL) shell
934 often requires a different set of quotation marks than Unix shells do.
935 For example:
936
937 $ perl -e "print ""Hello, world.\n"""
938 Hello, world.
939
940 There are several ways to wrap your perl scripts in DCL .COM files, if
941 you are so inclined. For example:
942
943 $ write sys$output "Hello from DCL!"
944 $ if p1 .eqs. ""
945 $ then perl -x 'f$environment("PROCEDURE")
946 $ else perl -x - 'p1 'p2 'p3 'p4 'p5 'p6 'p7 'p8
947 $ deck/dollars="__END__"
948 #!/usr/bin/perl
949
950 print "Hello from Perl!\n";
951
952 __END__
953 $ endif
954
955 Do take care with "$ ASSIGN/nolog/user SYS$COMMAND: SYS$INPUT" if your
956 perl-in-DCL script expects to do things like "$read = <STDIN>;".
957
958 The VMS operating system has two filesystems, known as ODS-2 and ODS-5.
959
960 For ODS-2, filenames are in the format "name.extension;version". The
961 maximum length for filenames is 39 characters, and the maximum length
962 for extensions is also 39 characters. Version is a number from 1 to
963 32767. Valid characters are "/[A-Z0-9$_-]/".
964
965 The ODS-2 filesystem is case-insensitive and does not preserve case.
966 Perl simulates this by converting all filenames to lowercase
967 internally.
968
969 For ODS-5, filenames may have almost any character in them and can
970 include Unicode characters. Characters that could be misinterpreted by
971 the DCL shell or file parsing utilities need to be prefixed with the
972 "^" character, or replaced with hexadecimal characters prefixed with
973 the "^" character. Such prefixing is only needed with the pathnames
974 are in VMS format in applications. Programs that can accept the Unix
975 format of pathnames do not need the escape characters. The maximum
976 length for filenames is 255 characters. The ODS-5 file system can
977 handle both a case preserved and a case sensitive mode.
978
979 ODS-5 is only available on the OpenVMS for 64 bit platforms.
980
981 Support for the extended file specifications is being done as optional
982 settings to preserve backward compatibility with Perl scripts that
983 assume the previous VMS limitations.
984
985 In general routines on VMS that get a Unix format file specification
986 should return it in a Unix format, and when they get a VMS format
987 specification they should return a VMS format unless they are
988 documented to do a conversion.
989
990 For routines that generate return a file specification, VMS allows
991 setting if the C library which Perl is built on if it will be returned
992 in VMS format or in Unix format.
993
994 With the ODS-2 file system, there is not much difference in syntax of
995 filenames without paths for VMS or Unix. With the extended character
996 set available with ODS-5 there can be a significant difference.
997
998 Because of this, existing Perl scripts written for VMS were sometimes
999 treating VMS and Unix filenames interchangeably. Without the extended
1000 character set enabled, this behavior will mostly be maintained for
1001 backwards compatibility.
1002
1003 When extended characters are enabled with ODS-5, the handling of Unix
1004 formatted file specifications is to that of a Unix system.
1005
1006 VMS file specifications without extensions have a trailing dot. An
1007 equivalent Unix file specification should not show the trailing dot.
1008
1009 The result of all of this, is that for VMS, for portable scripts, you
1010 can not depend on Perl to present the filenames in lowercase, to be
1011 case sensitive, and that the filenames could be returned in either Unix
1012 or VMS format.
1013
1014 And if a routine returns a file specification, unless it is intended to
1015 convert it, it should return it in the same format as it found it.
1016
1017 "readdir" by default has traditionally returned lowercased filenames.
1018 When the ODS-5 support is enabled, it will return the exact case of the
1019 filename on the disk.
1020
1021 Files without extensions have a trailing period on them, so doing a
1022 "readdir" in the default mode with a file named A.;5 will return a.
1023 when VMS is (though that file could be opened with "open(FH, 'A')").
1024
1025 With support for extended file specifications and if "opendir" was
1026 given a Unix format directory, a file named A.;5 will return a and
1027 optionally in the exact case on the disk. When "opendir" is given a
1028 VMS format directory, then "readdir" should return a., and again with
1029 the optionally the exact case.
1030
1031 RMS had an eight level limit on directory depths from any rooted
1032 logical (allowing 16 levels overall) prior to VMS 7.2, and even with
1033 versions of VMS on VAX up through 7.3. Hence
1034 "PERL_ROOT:[LIB.2.3.4.5.6.7.8]" is a valid directory specification but
1035 "PERL_ROOT:[LIB.2.3.4.5.6.7.8.9]" is not. Makefile.PL authors might
1036 have to take this into account, but at least they can refer to the
1037 former as "/PERL_ROOT/lib/2/3/4/5/6/7/8/".
1038
1039 Pumpkings and module integrators can easily see whether files with too
1040 many directory levels have snuck into the core by running the following
1041 in the top-level source directory:
1042
1043 $ perl -ne "$_=~s/\s+.*//; print if scalar(split /\//) > 8;" < MANIFEST
1044
1045 The VMS::Filespec module, which gets installed as part of the build
1046 process on VMS, is a pure Perl module that can easily be installed on
1047 non-VMS platforms and can be helpful for conversions to and from RMS
1048 native formats. It is also now the only way that you should check to
1049 see if VMS is in a case sensitive mode.
1050
1051 What "\n" represents depends on the type of file opened. It usually
1052 represents "\012" but it could also be "\015", "\012", "\015\012",
1053 "\000", "\040", or nothing depending on the file organization and
1054 record format. The VMS::Stdio module provides access to the special
1055 fopen() requirements of files with unusual attributes on VMS.
1056
1057 TCP/IP stacks are optional on VMS, so socket routines might not be
1058 implemented. UDP sockets may not be supported.
1059
1060 The TCP/IP library support for all current versions of VMS is
1061 dynamically loaded if present, so even if the routines are configured,
1062 they may return a status indicating that they are not implemented.
1063
1064 The value of $^O on OpenVMS is "VMS". To determine the architecture
1065 that you are running on without resorting to loading all of %Config you
1066 can examine the content of the @INC array like so:
1067
1068 if (grep(/VMS_AXP/, @INC)) {
1069 print "I'm on Alpha!\n";
1070
1071 } elsif (grep(/VMS_VAX/, @INC)) {
1072 print "I'm on VAX!\n";
1073
1074 } elsif (grep(/VMS_IA64/, @INC)) {
1075 print "I'm on IA64!\n";
1076
1077 } else {
1078 print "I'm not so sure about where $^O is...\n";
1079 }
1080
1081 In general, the significant differences should only be if Perl is
1082 running on VMS_VAX or one of the 64 bit OpenVMS platforms.
1083
1084 On VMS, perl determines the UTC offset from the
1085 "SYS$TIMEZONE_DIFFERENTIAL" logical name. Although the VMS epoch began
1086 at 17-NOV-1858 00:00:00.00, calls to "localtime" are adjusted to count
1087 offsets from 01-JAN-1970 00:00:00.00, just like Unix.
1088
1089 Also see:
1090
1091 · README.vms (installed as README_vms), perlvms
1092
1093 · vmsperl list, vmsperl-subscribe@perl.org
1094
1095 · vmsperl on the web, <http://www.sidhe.org/vmsperl/index.html>
1096
1097 VOS
1098 Perl on VOS (also known as OpenVOS) is discussed in README.vos in the
1099 perl distribution (installed as perlvos). Perl on VOS can accept
1100 either VOS- or Unix-style file specifications as in either of the
1101 following:
1102
1103 $ perl -ne "print if /perl_setup/i" >system>notices
1104 $ perl -ne "print if /perl_setup/i" /system/notices
1105
1106 or even a mixture of both as in:
1107
1108 $ perl -ne "print if /perl_setup/i" >system/notices
1109
1110 Even though VOS allows the slash character to appear in object names,
1111 because the VOS port of Perl interprets it as a pathname delimiting
1112 character, VOS files, directories, or links whose names contain a slash
1113 character cannot be processed. Such files must be renamed before they
1114 can be processed by Perl.
1115
1116 Older releases of VOS (prior to OpenVOS Release 17.0) limit file names
1117 to 32 or fewer characters, prohibit file names from starting with a "-"
1118 character, and prohibit file names from containing any character
1119 matching "tr/ !#%&'()*;<=>?//".
1120
1121 Newer releases of VOS (OpenVOS Release 17.0 or later) support a feature
1122 known as extended names. On these releases, file names can contain up
1123 to 255 characters, are prohibited from starting with a "-" character,
1124 and the set of prohibited characters is reduced to any character
1125 matching "tr/#%*<>?//". There are restrictions involving spaces and
1126 apostrophes: these characters must not begin or end a name, nor can
1127 they immediately precede or follow a period. Additionally, a space
1128 must not immediately precede another space or hyphen. Specifically,
1129 the following character combinations are prohibited: space-space,
1130 space-hyphen, period-space, space-period, period-apostrophe,
1131 apostrophe-period, leading or trailing space, and leading or trailing
1132 apostrophe. Although an extended file name is limited to 255
1133 characters, a path name is still limited to 256 characters.
1134
1135 The value of $^O on VOS is "VOS". To determine the architecture that
1136 you are running on without resorting to loading all of %Config you can
1137 examine the content of the @INC array like so:
1138
1139 if ($^O =~ /VOS/) {
1140 print "I'm on a Stratus box!\n";
1141 } else {
1142 print "I'm not on a Stratus box!\n";
1143 die;
1144 }
1145
1146 Also see:
1147
1148 · README.vos (installed as perlvos)
1149
1150 · The VOS mailing list.
1151
1152 There is no specific mailing list for Perl on VOS. You can post
1153 comments to the comp.sys.stratus newsgroup, or use the contact
1154 information located in the distribution files on the Stratus
1155 Anonymous FTP site.
1156
1157 · VOS Perl on the web at
1158 <http://ftp.stratus.com/pub/vos/posix/posix.html>
1159
1160 EBCDIC Platforms
1161 Recent versions of Perl have been ported to platforms such as OS/400 on
1162 AS/400 minicomputers as well as OS/390, VM/ESA, and BS2000 for S/390
1163 Mainframes. Such computers use EBCDIC character sets internally
1164 (usually Character Code Set ID 0037 for OS/400 and either 1047 or
1165 POSIX-BC for S/390 systems). On the mainframe perl currently works
1166 under the "Unix system services for OS/390" (formerly known as
1167 OpenEdition), VM/ESA OpenEdition, or the BS200 POSIX-BC system (BS2000
1168 is supported in perl 5.6 and greater). See perlos390 for details.
1169 Note that for OS/400 there is also a port of Perl 5.8.1/5.9.0 or later
1170 to the PASE which is ASCII-based (as opposed to ILE which is EBCDIC-
1171 based), see perlos400.
1172
1173 As of R2.5 of USS for OS/390 and Version 2.3 of VM/ESA these Unix sub-
1174 systems do not support the "#!" shebang trick for script invocation.
1175 Hence, on OS/390 and VM/ESA perl scripts can be executed with a header
1176 similar to the following simple script:
1177
1178 : # use perl
1179 eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
1180 if 0;
1181 #!/usr/local/bin/perl # just a comment really
1182
1183 print "Hello from perl!\n";
1184
1185 OS/390 will support the "#!" shebang trick in release 2.8 and beyond.
1186 Calls to "system" and backticks can use POSIX shell syntax on all S/390
1187 systems.
1188
1189 On the AS/400, if PERL5 is in your library list, you may need to wrap
1190 your perl scripts in a CL procedure to invoke them like so:
1191
1192 BEGIN
1193 CALL PGM(PERL5/PERL) PARM('/QOpenSys/hello.pl')
1194 ENDPGM
1195
1196 This will invoke the perl script hello.pl in the root of the QOpenSys
1197 file system. On the AS/400 calls to "system" or backticks must use CL
1198 syntax.
1199
1200 On these platforms, bear in mind that the EBCDIC character set may have
1201 an effect on what happens with some perl functions (such as "chr",
1202 "pack", "print", "printf", "ord", "sort", "sprintf", "unpack"), as well
1203 as bit-fiddling with ASCII constants using operators like "^", "&" and
1204 "|", not to mention dealing with socket interfaces to ASCII computers
1205 (see "Newlines").
1206
1207 Fortunately, most web servers for the mainframe will correctly
1208 translate the "\n" in the following statement to its ASCII equivalent
1209 ("\r" is the same under both Unix and OS/390 & VM/ESA):
1210
1211 print "Content-type: text/html\r\n\r\n";
1212
1213 The values of $^O on some of these platforms includes:
1214
1215 uname $^O $Config{'archname'}
1216 --------------------------------------------
1217 OS/390 os390 os390
1218 OS400 os400 os400
1219 POSIX-BC posix-bc BS2000-posix-bc
1220 VM/ESA vmesa vmesa
1221
1222 Some simple tricks for determining if you are running on an EBCDIC
1223 platform could include any of the following (perhaps all):
1224
1225 if ("\t" eq "\005") { print "EBCDIC may be spoken here!\n"; }
1226
1227 if (ord('A') == 193) { print "EBCDIC may be spoken here!\n"; }
1228
1229 if (chr(169) eq 'z') { print "EBCDIC may be spoken here!\n"; }
1230
1231 One thing you may not want to rely on is the EBCDIC encoding of
1232 punctuation characters since these may differ from code page to code
1233 page (and once your module or script is rumoured to work with EBCDIC,
1234 folks will want it to work with all EBCDIC character sets).
1235
1236 Also see:
1237
1238 · perlos390, README.os390, perlbs2000, README.vmesa, perlebcdic.
1239
1240 · The perl-mvs@perl.org list is for discussion of porting issues as
1241 well as general usage issues for all EBCDIC Perls. Send a message
1242 body of "subscribe perl-mvs" to majordomo@perl.org.
1243
1244 · AS/400 Perl information at <http://as400.rochester.ibm.com/> as
1245 well as on CPAN in the ports/ directory.
1246
1247 Acorn RISC OS
1248 Because Acorns use ASCII with newlines ("\n") in text files as "\012"
1249 like Unix, and because Unix filename emulation is turned on by default,
1250 most simple scripts will probably work "out of the box". The native
1251 filesystem is modular, and individual filesystems are free to be case-
1252 sensitive or insensitive, and are usually case-preserving. Some native
1253 filesystems have name length limits, which file and directory names are
1254 silently truncated to fit. Scripts should be aware that the standard
1255 filesystem currently has a name length limit of 10 characters, with up
1256 to 77 items in a directory, but other filesystems may not impose such
1257 limitations.
1258
1259 Native filenames are of the form
1260
1261 Filesystem#Special_Field::DiskName.$.Directory.Directory.File
1262
1263 where
1264
1265 Special_Field is not usually present, but may contain . and $ .
1266 Filesystem =~ m|[A-Za-z0-9_]|
1267 DsicName =~ m|[A-Za-z0-9_/]|
1268 $ represents the root directory
1269 . is the path separator
1270 @ is the current directory (per filesystem but machine global)
1271 ^ is the parent directory
1272 Directory and File =~ m|[^\0- "\.\$\%\&:\@\\^\|\177]+|
1273
1274 The default filename translation is roughly "tr|/.|./|;"
1275
1276 Note that ""ADFS::HardDisk.$.File" ne 'ADFS::HardDisk.$.File'" and that
1277 the second stage of "$" interpolation in regular expressions will fall
1278 foul of the $. if scripts are not careful.
1279
1280 Logical paths specified by system variables containing comma-separated
1281 search lists are also allowed; hence "System:Modules" is a valid
1282 filename, and the filesystem will prefix "Modules" with each section of
1283 "System$Path" until a name is made that points to an object on disk.
1284 Writing to a new file "System:Modules" would be allowed only if
1285 "System$Path" contains a single item list. The filesystem will also
1286 expand system variables in filenames if enclosed in angle brackets, so
1287 "<System$Dir>.Modules" would look for the file
1288 "$ENV{'System$Dir'} . 'Modules'". The obvious implication of this is
1289 that fully qualified filenames can start with "<>" and should be
1290 protected when "open" is used for input.
1291
1292 Because "." was in use as a directory separator and filenames could not
1293 be assumed to be unique after 10 characters, Acorn implemented the C
1294 compiler to strip the trailing ".c" ".h" ".s" and ".o" suffix from
1295 filenames specified in source code and store the respective files in
1296 subdirectories named after the suffix. Hence files are translated:
1297
1298 foo.h h.foo
1299 C:foo.h C:h.foo (logical path variable)
1300 sys/os.h sys.h.os (C compiler groks Unix-speak)
1301 10charname.c c.10charname
1302 10charname.o o.10charname
1303 11charname_.c c.11charname (assuming filesystem truncates at 10)
1304
1305 The Unix emulation library's translation of filenames to native assumes
1306 that this sort of translation is required, and it allows a user-defined
1307 list of known suffixes that it will transpose in this fashion. This
1308 may seem transparent, but consider that with these rules foo/bar/baz.h
1309 and foo/bar/h/baz both map to foo.bar.h.baz, and that "readdir" and
1310 "glob" cannot and do not attempt to emulate the reverse mapping. Other
1311 "."'s in filenames are translated to "/".
1312
1313 As implied above, the environment accessed through %ENV is global, and
1314 the convention is that program specific environment variables are of
1315 the form "Program$Name". Each filesystem maintains a current
1316 directory, and the current filesystem's current directory is the global
1317 current directory. Consequently, sociable programs don't change the
1318 current directory but rely on full pathnames, and programs (and
1319 Makefiles) cannot assume that they can spawn a child process which can
1320 change the current directory without affecting its parent (and everyone
1321 else for that matter).
1322
1323 Because native operating system filehandles are global and are
1324 currently allocated down from 255, with 0 being a reserved value, the
1325 Unix emulation library emulates Unix filehandles. Consequently, you
1326 can't rely on passing "STDIN", "STDOUT", or "STDERR" to your children.
1327
1328 The desire of users to express filenames of the form "<Foo$Dir>.Bar" on
1329 the command line unquoted causes problems, too: "``" command output
1330 capture has to perform a guessing game. It assumes that a string
1331 "<[^<>]+\$[^<>]>" is a reference to an environment variable, whereas
1332 anything else involving "<" or ">" is redirection, and generally
1333 manages to be 99% right. Of course, the problem remains that scripts
1334 cannot rely on any Unix tools being available, or that any tools found
1335 have Unix-like command line arguments.
1336
1337 Extensions and XS are, in theory, buildable by anyone using free tools.
1338 In practice, many don't, as users of the Acorn platform are used to
1339 binary distributions. MakeMaker does run, but no available make
1340 currently copes with MakeMaker's makefiles; even if and when this
1341 should be fixed, the lack of a Unix-like shell will cause problems with
1342 makefile rules, especially lines of the form "cd sdbm && make all", and
1343 anything using quoting.
1344
1345 "RISC OS" is the proper name for the operating system, but the value in
1346 $^O is "riscos" (because we don't like shouting).
1347
1348 Other perls
1349 Perl has been ported to many platforms that do not fit into any of the
1350 categories listed above. Some, such as AmigaOS, BeOS, HP MPE/iX, QNX,
1351 Plan 9, and VOS, have been well-integrated into the standard Perl
1352 source code kit. You may need to see the ports/ directory on CPAN for
1353 information, and possibly binaries, for the likes of: aos, Atari ST,
1354 lynxos, riscos, Novell Netware, Tandem Guardian, etc. (Yes, we know
1355 that some of these OSes may fall under the Unix category, but we are
1356 not a standards body.)
1357
1358 Some approximate operating system names and their $^O values in the
1359 "OTHER" category include:
1360
1361 OS $^O $Config{'archname'}
1362 ------------------------------------------
1363 Amiga DOS amigaos m68k-amigos
1364 BeOS beos
1365 MPE/iX mpeix PA-RISC1.1
1366
1367 See also:
1368
1369 · Amiga, README.amiga (installed as perlamiga).
1370
1371 · Be OS, README.beos
1372
1373 · HP 300 MPE/iX, README.mpeix and Mark Bixby's web page
1374 <http://www.bixby.org/mark/porting.html>
1375
1376 · A free perl5-based PERL.NLM for Novell Netware is available in
1377 precompiled binary and source code form from
1378 <http://www.novell.com/> as well as from CPAN.
1379
1380 · Plan 9, README.plan9
1381
1383 Listed below are functions that are either completely unimplemented or
1384 else have been implemented differently on various platforms. Following
1385 each description will be, in parentheses, a list of platforms that the
1386 description applies to.
1387
1388 The list may well be incomplete, or even wrong in some places. When in
1389 doubt, consult the platform-specific README files in the Perl source
1390 distribution, and any other documentation resources accompanying a
1391 given port.
1392
1393 Be aware, moreover, that even among Unix-ish systems there are
1394 variations.
1395
1396 For many functions, you can also query %Config, exported by default
1397 from the Config module. For example, to check whether the platform has
1398 the "lstat" call, check $Config{d_lstat}. See Config for a full
1399 description of available variables.
1400
1401 Alphabetical Listing of Perl Functions
1402 -X "-w" only inspects the read-only file attribute
1403 (FILE_ATTRIBUTE_READONLY), which determines whether the
1404 directory can be deleted, not whether it can be written to.
1405 Directories always have read and write access unless denied by
1406 discretionary access control lists (DACLs). (Win32)
1407
1408 "-r", "-w", "-x", and "-o" tell whether the file is accessible,
1409 which may not reflect UIC-based file protections. (VMS)
1410
1411 "-s" by name on an open file will return the space reserved on
1412 disk, rather than the current extent. "-s" on an open
1413 filehandle returns the current size. (RISC OS)
1414
1415 "-R", "-W", "-X", "-O" are indistinguishable from "-r", "-w",
1416 "-x", "-o". (Win32, VMS, RISC OS)
1417
1418 "-g", "-k", "-l", "-u", "-A" are not particularly meaningful.
1419 (Win32, VMS, RISC OS)
1420
1421 "-p" is not particularly meaningful. (VMS, RISC OS)
1422
1423 "-d" is true if passed a device spec without an explicit
1424 directory. (VMS)
1425
1426 "-x" (or "-X") determine if a file ends in one of the
1427 executable suffixes. "-S" is meaningless. (Win32)
1428
1429 "-x" (or "-X") determine if a file has an executable file type.
1430 (RISC OS)
1431
1432 alarm Emulated using timers that must be explicitly polled whenever
1433 Perl wants to dispatch "safe signals" and therefore cannot
1434 interrupt blocking system calls. (Win32)
1435
1436 atan2 Due to issues with various CPUs, math libraries, compilers, and
1437 standards, results for "atan2()" may vary depending on any
1438 combination of the above. Perl attempts to conform to the Open
1439 Group/IEEE standards for the results returned from "atan2()",
1440 but cannot force the issue if the system Perl is run on does
1441 not allow it. (Tru64, HP-UX 10.20)
1442
1443 The current version of the standards for "atan2()" is available
1444 at
1445 <http://www.opengroup.org/onlinepubs/009695399/functions/atan2.html>.
1446
1447 binmode Meaningless. (RISC OS)
1448
1449 Reopens file and restores pointer; if function fails,
1450 underlying filehandle may be closed, or pointer may be in a
1451 different position. (VMS)
1452
1453 The value returned by "tell" may be affected after the call,
1454 and the filehandle may be flushed. (Win32)
1455
1456 chmod Only good for changing "owner" read-write access, "group", and
1457 "other" bits are meaningless. (Win32)
1458
1459 Only good for changing "owner" and "other" read-write access.
1460 (RISC OS)
1461
1462 Access permissions are mapped onto VOS access-control list
1463 changes. (VOS)
1464
1465 The actual permissions set depend on the value of the "CYGWIN"
1466 in the SYSTEM environment settings. (Cygwin)
1467
1468 chown Not implemented. (Win32, Plan 9, RISC OS)
1469
1470 Does nothing, but won't fail. (Win32)
1471
1472 A little funky, because VOS's notion of ownership is a little
1473 funky (VOS).
1474
1475 chroot Not implemented. (Win32, VMS, Plan 9, RISC OS, VOS, VM/ESA)
1476
1477 crypt May not be available if library or source was not provided when
1478 building perl. (Win32)
1479
1480 dbmclose
1481 Not implemented. (VMS, Plan 9, VOS)
1482
1483 dbmopen Not implemented. (VMS, Plan 9, VOS)
1484
1485 dump Not useful. (RISC OS)
1486
1487 Not supported. (Cygwin, Win32)
1488
1489 Invokes VMS debugger. (VMS)
1490
1491 exec Implemented via Spawn. (VM/ESA)
1492
1493 Does not automatically flush output handles on some platforms.
1494 (SunOS, Solaris, HP-UX)
1495
1496 Not supported. (Symbian OS)
1497
1498 exit Emulates Unix exit() (which considers "exit 1" to indicate an
1499 error) by mapping the 1 to SS$_ABORT (44). This behavior may
1500 be overridden with the pragma "use vmsish 'exit'". As with the
1501 CRTL's exit() function, "exit 0" is also mapped to an exit
1502 status of SS$_NORMAL (1); this mapping cannot be overridden.
1503 Any other argument to exit() is used directly as Perl's exit
1504 status. On VMS, unless the future POSIX_EXIT mode is enabled,
1505 the exit code should always be a valid VMS exit code and not a
1506 generic number. When the POSIX_EXIT mode is enabled, a generic
1507 number will be encoded in a method compatible with the C
1508 library _POSIX_EXIT macro so that it can be decoded by other
1509 programs, particularly ones written in C, like the GNV package.
1510 (VMS)
1511
1512 "exit()" resets file pointers, which is a problem when called
1513 from a child process (created by "fork()") in "BEGIN". A
1514 workaround is to use "POSIX::_exit". (Solaris)
1515
1516 exit unless $Config{archname} =~ /\bsolaris\b/;
1517 require POSIX and POSIX::_exit(0);
1518
1519 fcntl Not implemented. (Win32)
1520
1521 Some functions available based on the version of VMS. (VMS)
1522
1523 flock Not implemented (VMS, RISC OS, VOS).
1524
1525 fork Not implemented. (AmigaOS, RISC OS, VM/ESA, VMS)
1526
1527 Emulated using multiple interpreters. See perlfork. (Win32)
1528
1529 Does not automatically flush output handles on some platforms.
1530 (SunOS, Solaris, HP-UX)
1531
1532 getlogin
1533 Not implemented. (RISC OS)
1534
1535 getpgrp Not implemented. (Win32, VMS, RISC OS)
1536
1537 getppid Not implemented. (Win32, RISC OS)
1538
1539 getpriority
1540 Not implemented. (Win32, VMS, RISC OS, VOS, VM/ESA)
1541
1542 getpwnam
1543 Not implemented. (Win32)
1544
1545 Not useful. (RISC OS)
1546
1547 getgrnam
1548 Not implemented. (Win32, VMS, RISC OS)
1549
1550 getnetbyname
1551 Not implemented. (Win32, Plan 9)
1552
1553 getpwuid
1554 Not implemented. (Win32)
1555
1556 Not useful. (RISC OS)
1557
1558 getgrgid
1559 Not implemented. (Win32, VMS, RISC OS)
1560
1561 getnetbyaddr
1562 Not implemented. (Win32, Plan 9)
1563
1564 getprotobynumber
1565 getservbyport
1566 getpwent
1567 Not implemented. (Win32, VM/ESA)
1568
1569 getgrent
1570 Not implemented. (Win32, VMS, VM/ESA)
1571
1572 gethostbyname
1573 "gethostbyname('localhost')" does not work everywhere: you may
1574 have to use "gethostbyname('127.0.0.1')". (Irix 5)
1575
1576 gethostent
1577 Not implemented. (Win32)
1578
1579 getnetent
1580 Not implemented. (Win32, Plan 9)
1581
1582 getprotoent
1583 Not implemented. (Win32, Plan 9)
1584
1585 getservent
1586 Not implemented. (Win32, Plan 9)
1587
1588 sethostent
1589 Not implemented. (Win32, Plan 9, RISC OS)
1590
1591 setnetent
1592 Not implemented. (Win32, Plan 9, RISC OS)
1593
1594 setprotoent
1595 Not implemented. (Win32, Plan 9, RISC OS)
1596
1597 setservent
1598 Not implemented. (Plan 9, Win32, RISC OS)
1599
1600 endpwent
1601 Not implemented. (MPE/iX, VM/ESA, Win32)
1602
1603 endgrent
1604 Not implemented. (MPE/iX, RISC OS, VM/ESA, VMS, Win32)
1605
1606 endhostent
1607 Not implemented. (Win32)
1608
1609 endnetent
1610 Not implemented. (Win32, Plan 9)
1611
1612 endprotoent
1613 Not implemented. (Win32, Plan 9)
1614
1615 endservent
1616 Not implemented. (Plan 9, Win32)
1617
1618 getsockopt SOCKET,LEVEL,OPTNAME
1619 Not implemented. (Plan 9)
1620
1621 glob This operator is implemented via the File::Glob extension on
1622 most platforms. See File::Glob for portability information.
1623
1624 gmtime In theory, gmtime() is reliable from -2**63 to 2**63-1.
1625 However, because work arounds in the implementation use
1626 floating point numbers, it will become inaccurate as the time
1627 gets larger. This is a bug and will be fixed in the future.
1628
1629 On VOS, time values are 32-bit quantities.
1630
1631 ioctl FILEHANDLE,FUNCTION,SCALAR
1632 Not implemented. (VMS)
1633
1634 Available only for socket handles, and it does what the
1635 ioctlsocket() call in the Winsock API does. (Win32)
1636
1637 Available only for socket handles. (RISC OS)
1638
1639 kill Not implemented, hence not useful for taint checking. (RISC OS)
1640
1641 "kill()" doesn't have the semantics of "raise()", i.e. it
1642 doesn't send a signal to the identified process like it does on
1643 Unix platforms. Instead "kill($sig, $pid)" terminates the
1644 process identified by $pid, and makes it exit immediately with
1645 exit status $sig. As in Unix, if $sig is 0 and the specified
1646 process exists, it returns true without actually terminating
1647 it. (Win32)
1648
1649 "kill(-9, $pid)" will terminate the process specified by $pid
1650 and recursively all child processes owned by it. This is
1651 different from the Unix semantics, where the signal will be
1652 delivered to all processes in the same process group as the
1653 process specified by $pid. (Win32)
1654
1655 Is not supported for process identification number of 0 or
1656 negative numbers. (VMS)
1657
1658 link Not implemented. (MPE/iX, RISC OS, VOS)
1659
1660 Link count not updated because hard links are not quite that
1661 hard (They are sort of half-way between hard and soft links).
1662 (AmigaOS)
1663
1664 Hard links are implemented on Win32 under NTFS only. They are
1665 natively supported on Windows 2000 and later. On Windows NT
1666 they are implemented using the Windows POSIX subsystem support
1667 and the Perl process will need Administrator or Backup Operator
1668 privileges to create hard links.
1669
1670 Available on 64 bit OpenVMS 8.2 and later. (VMS)
1671
1672 localtime
1673 localtime() has the same range as "gmtime", but because time
1674 zone rules change its accuracy for historical and future times
1675 may degrade but usually by no more than an hour.
1676
1677 lstat Not implemented. (RISC OS)
1678
1679 Return values (especially for device and inode) may be bogus.
1680 (Win32)
1681
1682 msgctl
1683 msgget
1684 msgsnd
1685 msgrcv Not implemented. (Win32, VMS, Plan 9, RISC OS, VOS)
1686
1687 open open to "|-" and "-|" are unsupported. (Win32, RISC OS)
1688
1689 Opening a process does not automatically flush output handles
1690 on some platforms. (SunOS, Solaris, HP-UX)
1691
1692 readlink
1693 Not implemented. (Win32, VMS, RISC OS)
1694
1695 rename Can't move directories between directories on different logical
1696 volumes. (Win32)
1697
1698 rewinddir
1699 Will not cause readdir() to re-read the directory stream. The
1700 entries already read before the rewinddir() call will just be
1701 returned again from a cache buffer. (Win32)
1702
1703 select Only implemented on sockets. (Win32, VMS)
1704
1705 Only reliable on sockets. (RISC OS)
1706
1707 Note that the "select FILEHANDLE" form is generally portable.
1708
1709 semctl
1710 semget
1711 semop Not implemented. (Win32, VMS, RISC OS)
1712
1713 setgrent
1714 Not implemented. (MPE/iX, VMS, Win32, RISC OS)
1715
1716 setpgrp Not implemented. (Win32, VMS, RISC OS, VOS)
1717
1718 setpriority
1719 Not implemented. (Win32, VMS, RISC OS, VOS)
1720
1721 setpwent
1722 Not implemented. (MPE/iX, Win32, RISC OS)
1723
1724 setsockopt
1725 Not implemented. (Plan 9)
1726
1727 shmctl
1728 shmget
1729 shmread
1730 shmwrite
1731 Not implemented. (Win32, VMS, RISC OS, VOS)
1732
1733 sockatmark
1734 A relatively recent addition to socket functions, may not be
1735 implemented even in Unix platforms.
1736
1737 socketpair
1738 Not implemented. (RISC OS, VM/ESA)
1739
1740 Available on OpenVOS Release 17.0 or later. (VOS)
1741
1742 Available on 64 bit OpenVMS 8.2 and later. (VMS)
1743
1744 stat Platforms that do not have rdev, blksize, or blocks will return
1745 these as '', so numeric comparison or manipulation of these
1746 fields may cause 'not numeric' warnings.
1747
1748 ctime not supported on UFS (Mac OS X).
1749
1750 ctime is creation time instead of inode change time (Win32).
1751
1752 device and inode are not meaningful. (Win32)
1753
1754 device and inode are not necessarily reliable. (VMS)
1755
1756 mtime, atime and ctime all return the last modification time.
1757 Device and inode are not necessarily reliable. (RISC OS)
1758
1759 dev, rdev, blksize, and blocks are not available. inode is not
1760 meaningful and will differ between stat calls on the same file.
1761 (os2)
1762
1763 some versions of cygwin when doing a stat("foo") and if not
1764 finding it may then attempt to stat("foo.exe") (Cygwin)
1765
1766 On Win32 stat() needs to open the file to determine the link
1767 count and update attributes that may have been changed through
1768 hard links. Setting ${^WIN32_SLOPPY_STAT} to a true value
1769 speeds up stat() by not performing this operation. (Win32)
1770
1771 symlink Not implemented. (Win32, RISC OS)
1772
1773 Implemented on 64 bit VMS 8.3. VMS requires the symbolic link
1774 to be in Unix syntax if it is intended to resolve to a valid
1775 path.
1776
1777 syscall Not implemented. (Win32, VMS, RISC OS, VOS, VM/ESA)
1778
1779 sysopen The traditional "0", "1", and "2" MODEs are implemented with
1780 different numeric values on some systems. The flags exported
1781 by "Fcntl" (O_RDONLY, O_WRONLY, O_RDWR) should work everywhere
1782 though. (Mac OS, OS/390, VM/ESA)
1783
1784 system As an optimization, may not call the command shell specified in
1785 $ENV{PERL5SHELL}. "system(1, @args)" spawns an external
1786 process and immediately returns its process designator, without
1787 waiting for it to terminate. Return value may be used
1788 subsequently in "wait" or "waitpid". Failure to spawn() a
1789 subprocess is indicated by setting $? to "255 << 8". $? is set
1790 in a way compatible with Unix (i.e. the exitstatus of the
1791 subprocess is obtained by "$? >> 8", as described in the
1792 documentation). (Win32)
1793
1794 There is no shell to process metacharacters, and the native
1795 standard is to pass a command line terminated by "\n" "\r" or
1796 "\0" to the spawned program. Redirection such as "> foo" is
1797 performed (if at all) by the run time library of the spawned
1798 program. "system" list will call the Unix emulation library's
1799 "exec" emulation, which attempts to provide emulation of the
1800 stdin, stdout, stderr in force in the parent, providing the
1801 child program uses a compatible version of the emulation
1802 library. scalar will call the native command line direct and
1803 no such emulation of a child Unix program will exists. Mileage
1804 will vary. (RISC OS)
1805
1806 Does not automatically flush output handles on some platforms.
1807 (SunOS, Solaris, HP-UX)
1808
1809 The return value is POSIX-like (shifted up by 8 bits), which
1810 only allows room for a made-up value derived from the severity
1811 bits of the native 32-bit condition code (unless overridden by
1812 "use vmsish 'status'"). If the native condition code is one
1813 that has a POSIX value encoded, the POSIX value will be decoded
1814 to extract the expected exit value. For more details see "$?"
1815 in perlvms. (VMS)
1816
1817 times "cumulative" times will be bogus. On anything other than
1818 Windows NT or Windows 2000, "system" time will be bogus, and
1819 "user" time is actually the time returned by the clock()
1820 function in the C runtime library. (Win32)
1821
1822 Not useful. (RISC OS)
1823
1824 truncate
1825 Not implemented. (Older versions of VMS)
1826
1827 Truncation to same-or-shorter lengths only. (VOS)
1828
1829 If a FILEHANDLE is supplied, it must be writable and opened in
1830 append mode (i.e., use "open(FH, '>>filename')" or
1831 "sysopen(FH,...,O_APPEND|O_RDWR)". If a filename is supplied,
1832 it should not be held open elsewhere. (Win32)
1833
1834 umask Returns undef where unavailable, as of version 5.005.
1835
1836 "umask" works but the correct permissions are set only when the
1837 file is finally closed. (AmigaOS)
1838
1839 utime Only the modification time is updated. (BeOS, VMS, RISC OS)
1840
1841 May not behave as expected. Behavior depends on the C runtime
1842 library's implementation of utime(), and the filesystem being
1843 used. The FAT filesystem typically does not support an "access
1844 time" field, and it may limit timestamps to a granularity of
1845 two seconds. (Win32)
1846
1847 wait
1848 waitpid Can only be applied to process handles returned for processes
1849 spawned using "system(1, ...)" or pseudo processes created with
1850 "fork()". (Win32)
1851
1852 Not useful. (RISC OS)
1853
1855 The following platforms are known to build Perl 5.12 (as of April 2010,
1856 its release date) from the standard source code distribution available
1857 at <http://www.cpan.org/src>
1858
1859 Linux (x86, ARM, IA64)
1860 HP-UX
1861 AIX
1862 Win32
1863 Windows 2000
1864 Windows XP
1865 Windows Server 2003
1866 Windows Vista
1867 Windows Server 2008
1868 Windows 7
1869 Cygwin
1870 Solaris (x86, SPARC)
1871 OpenVMS
1872 Alpha (7.2 and later)
1873 I64 (8.2 and later)
1874 Symbian
1875 NetBSD
1876 FreeBSD
1877 Debian GNU/kFreeBSD
1878 Haiku
1879 Irix (6.5. What else?)
1880 OpenBSD
1881 Dragonfly BSD
1882 QNX Neutrino RTOS (6.5.0)
1883 MirOS BSD
1884 Caveats:
1885
1886 time_t issues that may or may not be fixed
1887 Symbian (Series 60 v3, 3.2 and 5 - what else?)
1888 Stratus VOS / OpenVOS
1889 AIX
1890
1892 The following platforms were supported by a previous version of Perl
1893 but have been officially removed from Perl's source code as of 5.12:
1894
1895 Atari MiNT
1896 Apollo Domain/OS
1897 Apple Mac OS 8/9
1898 Tenon Machten
1899
1900 The following platforms were supported up to 5.10. They may still have
1901 worked in 5.12, but supporting code has been removed for 5.14:
1902
1903 Windows 95
1904 Windows 98
1905 Windows ME
1906 Windows NT4
1907
1909 As of July 2002 (the Perl release 5.8.0), the following platforms were
1910 able to build Perl from the standard source code distribution available
1911 at <http://www.cpan.org/src/>
1912
1913 AIX
1914 BeOS
1915 BSD/OS (BSDi)
1916 Cygwin
1917 DG/UX
1918 DOS DJGPP 1)
1919 DYNIX/ptx
1920 EPOC R5
1921 FreeBSD
1922 HI-UXMPP (Hitachi) (5.8.0 worked but we didn't know it)
1923 HP-UX
1924 IRIX
1925 Linux
1926 Mac OS Classic
1927 Mac OS X (Darwin)
1928 MPE/iX
1929 NetBSD
1930 NetWare
1931 NonStop-UX
1932 ReliantUNIX (formerly SINIX)
1933 OpenBSD
1934 OpenVMS (formerly VMS)
1935 Open UNIX (Unixware) (since Perl 5.8.1/5.9.0)
1936 OS/2
1937 OS/400 (using the PASE) (since Perl 5.8.1/5.9.0)
1938 PowerUX
1939 POSIX-BC (formerly BS2000)
1940 QNX
1941 Solaris
1942 SunOS 4
1943 SUPER-UX (NEC)
1944 Tru64 UNIX (formerly DEC OSF/1, Digital UNIX)
1945 UNICOS
1946 UNICOS/mk
1947 UTS
1948 VOS
1949 Win95/98/ME/2K/XP 2)
1950 WinCE
1951 z/OS (formerly OS/390)
1952 VM/ESA
1953
1954 1) in DOS mode either the DOS or OS/2 ports can be used
1955 2) compilers: Borland, MinGW (GCC), VC6
1956
1957 The following platforms worked with the previous releases (5.6 and
1958 5.7), but we did not manage either to fix or to test these in time for
1959 the 5.8.0 release. There is a very good chance that many of these will
1960 work fine with the 5.8.0.
1961
1962 BSD/OS
1963 DomainOS
1964 Hurd
1965 LynxOS
1966 MachTen
1967 PowerMAX
1968 SCO SV
1969 SVR4
1970 Unixware
1971 Windows 3.1
1972
1973 Known to be broken for 5.8.0 (but 5.6.1 and 5.7.2 can be used):
1974
1975 AmigaOS
1976
1977 The following platforms have been known to build Perl from source in
1978 the past (5.005_03 and earlier), but we haven't been able to verify
1979 their status for the current release, either because the
1980 hardware/software platforms are rare or because we don't have an active
1981 champion on these platforms--or both. They used to work, though, so go
1982 ahead and try compiling them, and let perlbug@perl.org of any trouble.
1983
1984 3b1
1985 A/UX
1986 ConvexOS
1987 CX/UX
1988 DC/OSx
1989 DDE SMES
1990 DOS EMX
1991 Dynix
1992 EP/IX
1993 ESIX
1994 FPS
1995 GENIX
1996 Greenhills
1997 ISC
1998 MachTen 68k
1999 MPC
2000 NEWS-OS
2001 NextSTEP
2002 OpenSTEP
2003 Opus
2004 Plan 9
2005 RISC/os
2006 SCO ODT/OSR
2007 Stellar
2008 SVR2
2009 TI1500
2010 TitanOS
2011 Ultrix
2012 Unisys Dynix
2013
2014 The following platforms have their own source code distributions and
2015 binaries available via <http://www.cpan.org/ports/>
2016
2017 Perl release
2018
2019 OS/400 (ILE) 5.005_02
2020 Tandem Guardian 5.004
2021
2022 The following platforms have only binaries available via
2023 <http://www.cpan.org/ports/index.html> :
2024
2025 Perl release
2026
2027 Acorn RISCOS 5.005_02
2028 AOS 5.002
2029 LynxOS 5.004_02
2030
2031 Although we do suggest that you always build your own Perl from the
2032 source code, both for maximal configurability and for security, in case
2033 you are in a hurry you can check <http://www.cpan.org/ports/index.html>
2034 for binary distributions.
2035
2037 perlaix, perlamiga, perlbeos, perlbs2000, perlce, perlcygwin, perldgux,
2038 perldos, perlepoc, perlebcdic, perlfreebsd, perlhurd, perlhpux,
2039 perlirix, perlmacos, perlmacosx, perlmpeix, perlnetware, perlos2,
2040 perlos390, perlos400, perlplan9, perlqnx, perlsolaris, perltru64,
2041 perlunicode, perlvmesa, perlvms, perlvos, perlwin32, and Win32.
2042
2044 Abigail <abigail@foad.org>, Charles Bailey <bailey@newman.upenn.edu>,
2045 Graham Barr <gbarr@pobox.com>, Tom Christiansen <tchrist@perl.com>,
2046 Nicholas Clark <nick@ccl4.org>, Thomas Dorner <Thomas.Dorner@start.de>,
2047 Andy Dougherty <doughera@lafayette.edu>, Dominic Dunlop
2048 <domo@computer.org>, Neale Ferguson <neale@vma.tabnsw.com.au>, David J.
2049 Fiander <davidf@mks.com>, Paul Green <Paul.Green@stratus.com>, M.J.T.
2050 Guy <mjtg@cam.ac.uk>, Jarkko Hietaniemi <jhi@iki.fi>, Luther Huffman
2051 <lutherh@stratcom.com>, Nick Ing-Simmons <nick@ing-simmons.net>,
2052 Andreas J. Koenig <a.koenig@mind.de>, Markus Laker
2053 <mlaker@contax.co.uk>, Andrew M. Langmead <aml@world.std.com>, Larry
2054 Moore <ljmoore@freespace.net>, Paul Moore
2055 <Paul.Moore@uk.origin-it.com>, Chris Nandor <pudge@pobox.com>, Matthias
2056 Neeracher <neeracher@mac.com>, Philip Newton <pne@cpan.org>, Gary Ng
2057 <71564.1743@CompuServe.COM>, Tom Phoenix <rootbeer@teleport.com>, Andre
2058 Pirard <A.Pirard@ulg.ac.be>, Peter Prymmer <pvhp@forte.com>, Hugo van
2059 der Sanden <hv@crypt0.demon.co.uk>, Gurusamy Sarathy
2060 <gsar@activestate.com>, Paul J. Schinder <schinder@pobox.com>, Michael
2061 G Schwern <schwern@pobox.com>, Dan Sugalski <dan@sidhe.org>, Nathan
2062 Torkington <gnat@frii.com>, John Malmberg <wb8tyw@qsl.net>
2063
2064
2065
2066perl v5.16.3 2013-03-04 PERLPORT(1)