3 perlport - Writing portable Perl
8 Perl runs on a variety of operating systems. While most of them share
9 a lot in common, they also have their own very particular and unique
12 This document is meant to help you to find out what constitutes portable
13 perl code, so that once you have made your decision to write portably,
14 you know where the lines are drawn, and you can stay within them.
16 There is a tradeoff between taking full advantage of B<a> particular type
17 of computer, and taking advantage of a full B<range> of them. Naturally,
18 as you make your range bigger (and thus more diverse), the common denominators
19 drop, and you are left with fewer areas of common ground in which
20 you can operate to accomplish a particular task. Thus, when you begin
21 attacking a problem, it is important to consider which part of the tradeoff
22 curve you want to operate under. Specifically, whether it is important to
23 you that the task that you are coding needs the full generality of being
24 portable, or if it is sufficient to just get the job done. This is the
25 hardest choice to be made. The rest is easy, because Perl provides lots
26 of choices, whichever way you want to approach your problem.
28 Looking at it another way, writing portable code is usually about willfully
29 limiting your available choices. Naturally, it takes discipline to do that.
31 Be aware of two important points:
35 =item Not all Perl programs have to be portable
37 There is no reason why you should not use Perl as a language to glue Unix
38 tools together, or to prototype a Macintosh application, or to manage the
39 Windows registry. If it makes no sense to aim for portability for one
40 reason or another in a given program, then don't bother.
42 =item The vast majority of Perl B<is> portable
44 Don't be fooled into thinking that it is hard to create portable Perl
45 code. It isn't. Perl tries its level-best to bridge the gaps between
46 what's available on different platforms, and all the means available to
47 use those features. Thus almost all Perl code runs on any machine
48 without modification. But there I<are> some significant issues in
49 writing portable code, and this document is entirely about those issues.
53 Here's the general rule: When you approach a task that is commonly done
54 using a whole range of platforms, think in terms of writing portable
55 code. That way, you don't sacrifice much by way of the implementation
56 choices you can avail yourself of, and at the same time you can give
57 your users lots of platform choices. On the other hand, when you have to
58 take advantage of some unique feature of a particular platform, as is
59 often the case with systems programming (whether for Unix, Windows,
60 S<Mac OS>, VMS, etc.), consider writing platform-specific code.
62 When the code will run on only two or three operating systems, then you may
63 only need to consider the differences of those particular systems. The
64 important thing is to decide where the code will run, and to be deliberate
67 This information should not be considered complete; it includes possibly
68 transient information about idiosyncracies of some of the ports, almost
69 all of which are in a state of constant evolution. Thus this material
70 should be considered a perpetual work in progress
71 (E<lt>IMG SRC="yellow_sign.gif" ALT="Under Construction"E<gt>).
78 In most operating systems, lines in files are separated with newlines.
79 Just what is used as a newline may vary from OS to OS. Unix
80 traditionally uses C<\012>, one kind of Windows I/O uses C<\015\012>,
81 and S<Mac OS> uses C<\015>.
83 Perl uses C<\n> to represent the "logical" newline, where what
84 is logical may depend on the platform in use. In MacPerl, C<\n>
85 always means C<\015>. In DOSish perls, C<\n> usually means C<\012>, but
86 when accessing a file in "text" mode, STDIO translates it to (or from)
89 Due to the "text" mode translation, DOSish perls have limitations
90 of using C<seek> and C<tell> when a file is being accessed in "text"
91 mode. Specifically, if you stick to C<seek>-ing to locations you got
92 from C<tell> (and no others), you are usually free to use C<seek> and
93 C<tell> even in "text" mode. In general, using C<seek> or C<tell> or
94 other file operations that count bytes instead of characters, without
95 considering the length of C<\n>, may be non-portable. If you use
96 C<binmode> on a file, however, you can usually use C<seek> and C<tell>
97 with arbitrary values quite safely.
99 A common misconception in socket programming is that C<\n> eq C<\012>
100 everywhere. When using protocols, such as common Internet protocols,
101 C<\012> and C<\015> are called for specifically, and the values of
102 the logical C<\n> and C<\r> (carriage return) are not reliable.
104 print SOCKET "Hi there, client!\r\n"; # WRONG
105 print SOCKET "Hi there, client!\015\012"; # RIGHT
107 [NOTE: this does not necessarily apply to communications that are
108 filtered by another program or module before sending to the socket; the
109 the most popular EBCDIC webserver, for instance, accepts C<\r\n>,
110 which translates those characters, along with all other
111 characters in text streams, from EBCDIC to ASCII.]
113 However, C<\015\012> (or C<\cM\cJ>, or C<\x0D\x0A>) can be tedious and
114 unsightly, as well as confusing to those maintaining the code. As such,
115 the C<Socket> module supplies the Right Thing for those who want it.
117 use Socket qw(:DEFAULT :crlf);
118 print SOCKET "Hi there, client!$CRLF" # RIGHT
120 When reading I<from> a socket, remember that the default input record
121 separator (C<$/>) is C<\n>, but code like this should recognize C<$/> as
122 C<\012> or C<\015\012>:
130 use Socket qw(:DEFAULT :crlf);
131 local($/) = LF; # not needed if $/ is already \012
134 s/$CR?$LF/\n/; # not sure if socket uses LF or CRLF, OK
135 # s/\015?\012/\n/; # same thing
138 And this example is actually better than the previous one even for Unix
139 platforms, because now any C<\015>'s (C<\cM>'s) are stripped out
140 (and there was much rejoicing).
145 Most platforms these days structure files in a hierarchical fashion.
146 So, it is reasonably safe to assume that any platform supports the
147 notion of a "path" to uniquely identify a file on the system. Just
148 how that path is actually written, differs.
150 While they are similar, file path specifications differ between Unix,
151 Windows, S<Mac OS>, OS/2, VMS and probably others. Unix, for example, is
152 one of the few OSes that has the idea of a root directory. S<Mac OS>
153 uses C<:> as a path separator instead of C</>. VMS, Windows, and OS/2
154 can work similarly to Unix with C</> as path separator, or in their own
157 As with the newline problem above, there are modules that can help. The
158 C<File::Spec> modules provide methods to do the Right Thing on whatever
159 platform happens to be running the program.
162 chdir(File::Spec->updir()); # go up one directory
163 $file = File::Spec->catfile(
164 File::Spec->curdir(), 'temp', 'file.txt'
166 # on Unix and Win32, './temp/file.txt'
167 # on Mac OS, ':temp:file.txt'
169 File::Spec is available in the standard distribution, as of version
172 In general, production code should not have file paths hardcoded; making
173 them user supplied or from a configuration file is better, keeping in mind
174 that file path syntax varies on different machines.
176 This is especially noticeable in scripts like Makefiles and test suites,
177 which often assume C</> as a path separator for subdirectories.
179 Also of use is C<File::Basename>, from the standard distribution, which
180 splits a pathname into pieces (base filename, full path to directory,
183 Remember not to count on the existence of system-specific files, like
184 F</etc/resolv.conf>. If code does need to rely on such a file, include a
185 description of the file and its format in the code's documentation, and
186 make it easy for the user to override the default location of the file.
189 =head2 System Interaction
191 Not all platforms provide for the notion of a command line, necessarily.
192 These are usually platforms that rely on a Graphical User Interface (GUI)
193 for user interaction. So a program requiring command lines might not work
194 everywhere. But this is probably for the user of the program to deal
197 Some platforms can't delete or rename files that are being held open by
198 the system. Remember to C<close> files when you are done with them.
199 Don't C<unlink> or C<rename> an open file. Don't C<tie> to or C<open> a
200 file that is already tied to or opened; C<untie> or C<close> first.
202 Don't count on a specific environment variable existing in C<%ENV>.
203 Don't even count on C<%ENV> entries being case-sensitive, or even
206 Don't count on signals in portable programs.
208 Don't count on filename globbing. Use C<opendir>, C<readdir>, and
212 =head2 Interprocess Communication (IPC)
214 In general, don't directly access the system in code that is meant to be
215 portable. That means, no: C<system>, C<exec>, C<fork>, C<pipe>, C<``>,
216 C<qx//>, C<open> with a C<|>, or any of the other things that makes being
217 a Unix perl hacker worth being.
219 Commands that launch external processes are generally supported on
220 most platforms (though many of them do not support any type of forking),
221 but the problem with using them arises from what you invoke with them.
222 External tools are often named differently on different platforms, often
223 not available in the same location, often accept different arguments,
224 often behave differently, and often represent their results in a
225 platform-dependent way. Thus you should seldom depend on them to produce
228 One especially common bit of Perl code is opening a pipe to sendmail:
230 open(MAIL, '|/usr/lib/sendmail -t') or die $!;
232 This is fine for systems programming when sendmail is known to be
233 available. But it is not fine for many non-Unix systems, and even
234 some Unix systems that may not have sendmail installed. If a portable
235 solution is needed, see the C<Mail::Send> and C<Mail::Mailer> modules
236 in the C<MailTools> distribution. C<Mail::Mailer> provides several
237 mailing methods, including mail, sendmail, and direct SMTP
238 (via C<Net::SMTP>) if a mail transfer agent is not available.
240 The rule of thumb for portable code is: Do it all in portable Perl, or
241 use a module that may internally implement it with platform-specific code,
242 but expose a common interface. By portable Perl, we mean code that
243 avoids the constructs described in this document as being non-portable.
246 =head2 External Subroutines (XS)
248 XS code, in general, can be made to work with any platform; but dependent
249 libraries, header files, etc., might not be readily available or
250 portable, or the XS code itself might be platform-specific, just as Perl
251 code might be. If the libraries and headers are portable, then it is
252 normally reasonable to make sure the XS code is portable, too.
254 There is a different kind of portability issue with writing XS
255 code: availability of a C compiler on the end-user's system. C brings with
256 it its own portability issues, and writing XS code will expose you to
257 some of those. Writing purely in perl is a comparatively easier way to
261 =head2 Standard Modules
263 In general, the standard modules work across platforms. Notable
264 exceptions are C<CPAN.pm> (which currently makes connections to external
265 programs that may not be available), platform-specific modules (like
266 C<ExtUtils::MM_VMS>), and DBM modules.
268 There is no one DBM module that is available on all platforms.
269 C<SDBM_File> and the others are generally available on all Unix and DOSish
270 ports, but not in MacPerl, where C<NBDM_File> and C<DB_File> are available.
272 The good news is that at least some DBM module should be available, and
273 C<AnyDBM_File> will use whichever module it can find. Of course, then
274 the code needs to be fairly strict, dropping to the lowest common
275 denominator (e.g., not exceeding 1K for each record).
280 The system's notion of time of day and calendar date is controlled in widely
281 different ways. Don't assume the timezone is stored in C<$ENV{TZ}>, and even
282 if it is, don't assume that you can control the timezone through that
285 Don't assume that the epoch starts at January 1, 1970, because that is
286 OS-specific. Better to store a date in an unambiguous representation.
287 A text representation (like C<1 Jan 1970>) can be easily converted into an
288 OS-specific value using a module like C<Date::Parse>. An array of values,
289 such as those returned by C<localtime>, can be converted to an OS-specific
290 representation using C<Time::Local>.
293 =head2 System Resources
295 If your code is destined for systems with severely constrained (or missing!)
296 virtual memory systems then you want to be especially mindful of avoiding
297 wasteful constructs such as:
299 # NOTE: this is no longer "bad" in perl5.005
300 for (0..10000000) {} # bad
301 for (my $x = 0; $x <= 10000000; ++$x) {} # good
303 @lines = <VERY_LARGE_FILE>; # bad
305 while (<FILE>) {$file .= $_} # sometimes bad
306 $file = join '', <FILE>; # better
308 The last two may appear unintuitive to most people. The first of those
309 two constructs repeatedly grows a string, while the second allocates a
310 large chunk of memory in one go. On some systems, the latter is more
311 efficient that the former.
315 Most Unix platforms provide basic levels of security that is usually felt
316 at the file-system level. Other platforms usually don't (unfortunately).
317 Thus the notion of User-ID, or "home" directory, or even the state of
318 being logged-in may be unrecognizable on may platforms. If you write
319 programs that are security conscious, it is usually best to know what
320 type of system you will be operating under, and write code explicitly
321 for that platform (or class of platforms).
325 For those times when it is necessary to have platform-specific code,
326 consider keeping the platform-specific code in one place, making porting
327 to other platforms easier. Use the C<Config> module and the special
328 variable C<$^O> to differentiate platforms, as described in L<"PLATFORMS">.
333 Module uploaded to CPAN are tested by a variety of volunteers on
334 different platforms. These CPAN testers are notified by e-mail of each
335 new upload, and reply to the list with PASS, FAIL, NA (not applicable to
336 this platform), or ???? (unknown), along with any relevant notations.
338 The purpose of the testing is twofold: one, to help developers fix any
339 problems in their code; two, to provide users with information about
340 whether or not a given module works on a given platform.
344 =item Mailing list: cpan-testers@perl.org
346 =item Testing results: C<http://www.connect.net/gbarr/cpan-test/>
353 As of version 5.002, Perl is built with a C<$^O> variable that
354 indicates the operating system it was built on. This was implemented
355 to help speed up code that would otherwise have to C<use Config;> and
356 use the value of C<$Config{'osname'}>. Of course, to get
357 detailed information about the system, looking into C<%Config> is
358 certainly recommended.
362 Perl works on a bewildering variety of Unix and Unix-like platforms (see
363 e.g. most of the files in the F<hints/> directory in the source code kit).
364 On most of these systems, the value of C<$^O> (hence C<$Config{'osname'}>,
365 too) is determined by lowercasing and stripping punctuation from the first
366 field of the string returned by typing
370 (or a similar command) at the shell prompt. Here, for example, are a few
371 of the more popular Unix flavors:
384 =head2 DOS and Derivatives
386 Perl has long been ported to PC style microcomputers running under
387 systems like PC-DOS, MS-DOS, OS/2, and most Windows platforms you can
388 bring yourself to mention (except for Windows CE, if you count that).
389 Users familiar with I<COMMAND.COM> and/or I<CMD.EXE> style shells should
390 be aware that each of these file specifications may have subtle
393 $filespec0 = "c:/foo/bar/file.txt";
394 $filespec1 = "c:\\foo\\bar\\file.txt";
395 $filespec2 = 'c:\foo\bar\file.txt';
396 $filespec3 = 'c:\\foo\\bar\\file.txt';
398 System calls accept either C</> or C<\> as the path separator. However,
399 many command-line utilities of DOS vintage treat C</> as the option
400 prefix, so they may get confused by filenames containing C</>. Aside
401 from calling any external programs, C</> will work just fine, and
402 probably better, as it is more consistent with popular usage, and avoids
403 the problem of remembering what to backwhack and what not to.
405 The DOS FAT file system can only accomodate "8.3" style filenames. Under
406 the "case insensitive, but case preserving" HPFS (OS/2) and NTFS (NT)
407 file systems you may have to be careful about case returned with functions
408 like C<readdir> or used with functions like C<open> or C<opendir>.
410 DOS also treats several filenames as special, such as AUX, PRN, NUL, CON,
411 COM1, LPT1, LPT2 etc. Unfortunately these filenames won't even work
412 if you include an explicit directory prefix, in some cases. It is best
413 to avoid such filenames, if you want your code to be portable to DOS
416 Users of these operating systems may also wish to make use of
417 scripts such as I<pl2bat.bat> or I<pl2cmd> as appropriate to
418 put wrappers around your scripts.
420 Newline (C<\n>) is translated as C<\015\012> by STDIO when reading from
421 and writing to files. C<binmode(FILEHANDLE)> will keep C<\n> translated
422 as C<\012> for that filehandle. Since it is a noop on other systems,
423 C<binmode> should be used for cross-platform code that deals with binary
426 The C<$^O> variable and the C<$Config{'archname'}> values for various
427 DOSish perls are as follows:
429 OS $^O $Config{'archname'}
430 --------------------------------------------
434 Windows 95 MSWin32 MSWin32-x86
435 Windows NT MSWin32 MSWin32-x86
436 Windows NT MSWin32 MSWin32-alpha
437 Windows NT MSWin32 MSWin32-ppc
443 =item The djgpp environment for DOS, C<http://www.delorie.com/djgpp/>
445 =item The EMX environment for DOS, OS/2, etc. C<emx@iaehv.nl>,
446 C<http://www.juge.com/bbs/Hobb.19.html>
448 =item Build instructions for Win32, L<perlwin32>.
450 =item The ActiveState Pages, C<http://www.activestate.com/>
457 Any module requiring XS compilation is right out for most people, because
458 MacPerl is built using non-free (and non-cheap!) compilers. Some XS
459 modules that can work with MacPerl are built and distributed in binary
460 form on CPAN. See I<MacPerl: Power and Ease> for more details.
462 Directories are specified as:
464 volume:folder:file for absolute pathnames
465 volume:folder: for absolute pathnames
466 :folder:file for relative pathnames
467 :folder: for relative pathnames
468 :file for relative pathnames
469 file for relative pathnames
471 Files in a directory are stored in alphabetical order. Filenames are
472 limited to 31 characters, and may include any character except C<:>,
473 which is reserved as a path separator.
475 Instead of C<flock>, see C<FSpSetFLock> and C<FSpRstFLock> in
478 In the MacPerl application, you can't run a program from the command line;
479 programs that expect C<@ARGV> to be populated can be edited with something
480 like the following, which brings up a dialog box asking for the command
484 @ARGV = split /\s+/, MacPerl::Ask('Arguments?');
487 A MacPerl script saved as a droplet will populate C<@ARGV> with the full
488 pathnames of the files dropped onto the script.
490 Mac users can use programs on a kind of command line under MPW (Macintosh
491 Programmer's Workshop, a free development environment from Apple).
492 MacPerl was first introduced as an MPW tool, and MPW can be used like a
495 perl myscript.plx some arguments
497 ToolServer is another app from Apple that provides access to MPW tools
498 from MPW and the MacPerl app, which allows MacPerl program to use
499 C<system>, backticks, and piped C<open>.
501 "S<Mac OS>" is the proper name for the operating system, but the value
502 in C<$^O> is "MacOS". To determine architecture, version, or whether
503 the application or MPW tool version is running, check:
505 $is_app = $MacPerl::Version =~ /App/;
506 $is_tool = $MacPerl::Version =~ /MPW/;
507 ($version) = $MacPerl::Version =~ /^(\S+)/;
508 $is_ppc = $MacPerl::Architecture eq 'MacPPC';
509 $is_68k = $MacPerl::Architecture eq 'Mac68K';
516 =item The MacPerl Pages, C<http://www.ptf.com/macperl/>.
518 =item The MacPerl mailing list, C<mac-perl-request@iis.ee.ethz.ch>.
525 Perl on VMS is discussed in F<vms/perlvms.pod> in the perl distribution.
526 Note that perl on VMS can accept either VMS or Unix style file
527 specifications as in either of the following:
529 $ perl -ne "print if /perl_setup/i" SYS$LOGIN:LOGIN.COM
530 $ perl -ne "print if /perl_setup/i" /sys$login/login.com
532 but not a mixture of both as in:
534 $ perl -ne "print if /perl_setup/i" sys$login:/login.com
535 Can't open sys$login:/login.com: file specification syntax error
537 Interacting with Perl from the Digital Command Language (DCL) shell
538 often requires a different set of quotation marks than Unix shells do.
541 $ perl -e "print ""Hello, world.\n"""
544 There are a number of ways to wrap your perl scripts in DCL .COM files if
545 you are so inclined. For example:
547 $ write sys$output "Hello from DCL!"
549 $ then perl -x 'f$environment("PROCEDURE")
550 $ else perl -x - 'p1 'p2 'p3 'p4 'p5 'p6 'p7 'p8
551 $ deck/dollars="__END__"
554 print "Hello from Perl!\n";
559 Do take care with C<$ ASSIGN/nolog/user SYS$COMMAND: SYS$INPUT> if your
560 perl-in-DCL script expects to do things like C<$read = E<lt>STDINE<gt>;>.
562 Filenames are in the format "name.extension;version". The maximum
563 length for filenames is 39 characters, and the maximum length for
564 extensions is also 39 characters. Version is a number from 1 to
565 32767. Valid characters are C</[A-Z0-9$_-]/>.
567 VMS' RMS filesystem is case insensitive and does not preserve case.
568 C<readdir> returns lowercased filenames, but specifying a file for
569 opening remains case insensitive. Files without extensions have a
570 trailing period on them, so doing a C<readdir> with a file named F<A.;5>
571 will return F<a.> (though that file could be opened with C<open(FH, 'A')>.
573 RMS has an eight level limit on directory depths from any rooted logical
574 (allowing 16 levels overall). Hence C<PERL_ROOT:[LIB.2.3.4.5.6.7.8]>
575 is a valid directory specification but C<PERL_ROOT:[LIB.2.3.4.5.6.7.8.9]>
576 is not. F<Makefile.PL> authors might have to take this into account, but
577 at least they can refer to the former as C</PERL_ROOT/lib/2/3/4/5/6/7/8/>.
579 The C<VMS::Filespec> module, which gets installed as part
580 of the build process on VMS, is a pure Perl module that can easily be
581 installed on non-VMS platforms and can be helpful for conversions to
582 and from RMS native formats.
584 What C<\n> represents depends on the type of file that is open. It could
585 be C<\015>, C<\012>, C<\015\012>, or nothing. Reading from a file
586 translates newlines to C<\012>, unless C<binmode> was executed on that
587 handle, just like DOSish perls.
589 TCP/IP stacks are optional on VMS, so socket routines might not be
590 implemented. UDP sockets may not be supported.
592 The value of C<$^O> on OpenVMS is "VMS". To determine the architecture
593 that you are running on without resorting to loading all of C<%Config>
594 you can examine the content of the C<@INC> array like so:
596 if (grep(/VMS_AXP/, @INC)) {
597 print "I'm on Alpha!\n";
598 } elsif (grep(/VMS_VAX/, @INC)) {
599 print "I'm on VAX!\n";
601 print "I'm not so sure about where $^O is...\n";
610 =item vmsperl list, C<vmsperl-request@newman.upenn.edu>
612 Put words C<SUBSCRIBE VMSPERL> in message body.
614 =item vmsperl on the web, C<http://www.sidhe.org/vmsperl/index.html>
619 =head2 EBCDIC Platforms
621 Recent versions of Perl have been ported to platforms such as OS/400 on
622 AS/400 minicomputers as well as OS/390 for IBM Mainframes. Such computers
623 use EBCDIC character sets internally (usually Character Code Set ID 00819
624 for OS/400 and IBM-1047 for OS/390). Note that on the mainframe perl
625 currently works under the "Unix system services for OS/390" (formerly
626 known as OpenEdition).
628 As of R2.5 of USS for OS/390 that Unix sub-system did not support the
629 C<#!> shebang trick for script invocation. Hence, on OS/390 perl scripts
630 can executed with a header similar to the following simple script:
633 eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
635 #!/usr/local/bin/perl # just a comment really
637 print "Hello from perl!\n";
639 On these platforms, bear in mind that the EBCDIC character set may have
640 an effect on what happens with perl functions such as C<chr>, C<pack>,
641 C<print>, C<printf>, C<ord>, C<sort>, C<sprintf>, C<unpack>; as well as
642 bit-fiddling with ASCII constants using operators like C<^>, C<&> and
643 C<|>; not to mention dealing with socket interfaces to ASCII computers
646 Fortunately, most web servers for the mainframe will correctly translate
647 the C<\n> in the following statement to its ASCII equivalent (note that
648 C<\r> is the same under both ASCII and EBCDIC):
650 print "Content-type: text/html\r\n\r\n";
652 The value of C<$^O> on OS/390 is "os390".
654 Some simple tricks for determining if you are running on an EBCDIC
655 platform could include any of the following (perhaps all):
657 if ("\t" eq "\05") { print "EBCDIC may be spoken here!\n"; }
659 if (ord('A') == 193) { print "EBCDIC may be spoken here!\n"; }
661 if (chr(169) eq 'z') { print "EBCDIC may be spoken here!\n"; }
663 Note that one thing you may not want to rely on is the EBCDIC encoding
664 of punctuation characters since these may differ from code page to code page
665 (and once your module or script is rumoured to work with EBCDIC, folks will
666 want it to work with all EBCDIC character sets).
674 The perl-mvs@perl.org list is for discussion of porting issues as well as
675 general usage issues for all EBCDIC Perls. Send a message body of
676 "subscribe perl-mvs" to majordomo@perl.org.
678 =item AS/400 Perl information at C<http://as400.rochester.ibm.com>
684 Perl has been ported to a variety of platforms that do not fit into any of
685 the above categories. Some, such as AmigaOS, BeOS, QNX, and Plan 9, have
686 been well integrated into the standard Perl source code kit. You may need
687 to see the F<ports/> directory on CPAN for information, and possibly
688 binaries, for the likes of: acorn, aos, atari, lynxos, HP-MPE/iX, riscos,
689 Tandem Guardian, vos, I<etc.> (yes we know that some of these OSes may fall
690 under the Unix category but we are not a standards body.)
696 =item Atari, Guido Flohr's page C<http://stud.uni-sb.de/~gufl0000/>
698 =item HP 300 MPE/iX C<http://www.cccd.edu/~markb/perlix.html>
702 A free Perl 5 based PERL.NLM for Novell Netware is available from
703 C<http://www.novell.com/>
708 =head1 FUNCTION IMPLEMENTATIONS
710 Listed below are functions unimplemented or implemented differently on
711 various platforms. Following each description will be, in parentheses, a
712 list of platforms that the description applies to.
714 The list may very well be incomplete, or wrong in some places. When in
715 doubt, consult the platform-specific README files in the Perl source
716 distribution, and other documentation resources for a given port.
718 Be aware, moreover, that even among Unix-ish systems there are variations,
719 and not all functions listed here are necessarily available, though
722 For many functions, you can also query C<%Config>, exported by default
723 from C<Config.pm>. For example, to check if the platform has the C<lstat>
724 call, check C<$Config{'d_lstat'}>. See L<Config> for a full description
725 of available variables.
728 =head2 Alphabetical Listing of Perl Functions
738 C<-r>, C<-w>, and C<-x> have only a very limited meaning; directories
739 and applications are executable, and there are no uid/gid
740 considerations. C<-o> is not supported. (S<Mac OS>)
742 C<-r>, C<-w>, C<-x>, and C<-o> tell whether or not file is accessible,
743 which may not reflect UIC-based file protections. (VMS)
745 C<-R>, C<-W>, C<-X>, C<-O> are indistinguishable from C<-r>, C<-w>,
746 C<-x>, C<-o>. (S<Mac OS>, Win32, VMS)
748 C<-b>, C<-c>, C<-k>, C<-g>, C<-p>, C<-u>, C<-A> are not implemented.
751 C<-g>, C<-k>, C<-l>, C<-p>, C<-u>, C<-A> are not particularly meaningful.
754 C<-d> is true if passed a device spec without an explicit directory.
757 C<-T> and C<-B> are implemented, but might misclassify Mac text files
758 with foreign characters; this is the case will all platforms, but
759 affects S<Mac OS> a lot. (S<Mac OS>)
761 C<-x> (or C<-X>) determine if a file ends in one of the executable
762 suffixes. C<-S> is meaningless. (Win32)
764 =item binmode FILEHANDLE
766 Meaningless. (S<Mac OS>)
768 Reopens file and restores pointer; if function fails, underlying
769 filehandle may be closed, or pointer may be in a different position.
772 The value returned by C<tell> may be affected after the call, and
773 the filehandle may be flushed. (Win32)
777 Only limited meaning. Disabling/enabling write permission is mapped to
778 locking/unlocking the file. (S<Mac OS>)
780 Only good for changing "owner" read-write access, "group", and "other"
781 bits are meaningless. (Win32)
785 Not implemented. (S<Mac OS>, Win32, Plan9)
787 Does nothing, but won't fail. (Win32)
789 =item chroot FILENAME
793 Not implemented. (S<Mac OS>, Win32, VMS, Plan9)
795 =item crypt PLAINTEXT,SALT
797 May not be available if library or source was not provided when building
802 Not implemented. (VMS, Plan9)
804 =item dbmopen HASH,DBNAME,MODE
806 Not implemented. (VMS, Plan9)
810 Not useful. (S<Mac OS>)
812 Not implemented. (Win32)
814 Invokes VMS debugger. (VMS)
818 Not implemented. (S<Mac OS>)
820 =item fcntl FILEHANDLE,FUNCTION,SCALAR
822 Not implemented. (Win32, VMS)
824 =item flock FILEHANDLE,OPERATION
826 Not implemented (S<Mac OS>, VMS).
828 Available only on Windows NT (not on Windows 95). (Win32)
832 Not implemented. (S<Mac OS>, Win32, AmigaOS)
836 Not implemented. (S<Mac OS>)
840 Not implemented. (S<Mac OS>, Win32, VMS)
844 Not implemented. (S<Mac OS>, Win32, VMS)
846 =item getpriority WHICH,WHO
848 Not implemented. (S<Mac OS>, Win32, VMS)
852 Not implemented. (S<Mac OS>, Win32)
856 Not implemented. (S<Mac OS>, Win32, VMS)
858 =item getnetbyname NAME
860 Not implemented. (S<Mac OS>, Win32, Plan9)
864 Not implemented. (S<Mac OS>, Win32)
868 Not implemented. (S<Mac OS>, Win32, VMS)
870 =item getnetbyaddr ADDR,ADDRTYPE
872 Not implemented. (S<Mac OS>, Win32, Plan9)
874 =item getprotobynumber NUMBER
876 Not implemented. (S<Mac OS>)
878 =item getservbyport PORT,PROTO
880 Not implemented. (S<Mac OS>)
884 Not implemented. (S<Mac OS>, Win32)
888 Not implemented. (S<Mac OS>, Win32, VMS)
892 Not implemented. (S<Mac OS>, Win32)
896 Not implemented. (S<Mac OS>, Win32, Plan9)
900 Not implemented. (S<Mac OS>, Win32, Plan9)
904 Not implemented. (Win32, Plan9)
908 Not implemented. (S<Mac OS>, Win32)
912 Not implemented. (S<Mac OS>, Win32, VMS)
914 =item sethostent STAYOPEN
916 Not implemented. (S<Mac OS>, Win32, Plan9)
918 =item setnetent STAYOPEN
920 Not implemented. (S<Mac OS>, Win32, Plan9)
922 =item setprotoent STAYOPEN
924 Not implemented. (S<Mac OS>, Win32, Plan9)
926 =item setservent STAYOPEN
928 Not implemented. (Plan9, Win32)
932 Not implemented. (S<Mac OS>, Win32)
936 Not implemented. (S<Mac OS>, Win32, VMS)
940 Not implemented. (S<Mac OS>, Win32)
944 Not implemented. (S<Mac OS>, Win32, Plan9)
948 Not implemented. (S<Mac OS>, Win32, Plan9)
952 Not implemented. (Plan9, Win32)
954 =item getsockopt SOCKET,LEVEL,OPTNAME
956 Not implemented. (S<Mac OS>, Plan9)
962 Globbing built-in, but only C<*> and C<?> metacharacters are supported.
965 Features depend on external perlglob.exe or perlglob.bat. May be overridden
966 with something like File::DosGlob, which is recommended. (Win32)
968 =item ioctl FILEHANDLE,FUNCTION,SCALAR
970 Not implemented. (VMS)
972 Available only for socket handles, and it does what the ioctlsocket() call
973 in the Winsock API does. (Win32)
977 Not implemented. (S<Mac OS>)
979 Available only for process handles returned by the C<system(1, ...)> method of
980 spawning a process. (Win32)
982 =item link OLDFILE,NEWFILE
984 Not implemented. (S<Mac OS>, Win32, VMS)
986 =item lstat FILEHANDLE
992 Not implemented. (VMS)
994 Return values may be bogus. (Win32)
996 =item msgctl ID,CMD,ARG
998 =item msgget KEY,FLAGS
1000 =item msgsnd ID,MSG,FLAGS
1002 =item msgrcv ID,VAR,SIZE,TYPE,FLAGS
1004 Not implemented. (S<Mac OS>, Win32, VMS, Plan9)
1006 =item open FILEHANDLE,EXPR
1008 =item open FILEHANDLE
1010 The C<|> variants are only supported if ToolServer is installed.
1013 open to C<|-> and C<-|> are unsupported. (S<Mac OS>, Win32)
1015 =item pipe READHANDLE,WRITEHANDLE
1017 Not implemented. (S<Mac OS>)
1023 Not implemented. (Win32, VMS)
1025 =item select RBITS,WBITS,EBITS,TIMEOUT
1027 Only implemented on sockets. (Win32)
1029 =item semctl ID,SEMNUM,CMD,ARG
1031 =item semget KEY,NSEMS,FLAGS
1033 =item semop KEY,OPSTRING
1035 Not implemented. (S<Mac OS>, Win32, VMS)
1037 =item setpgrp PID,PGRP
1039 Not implemented. (S<Mac OS>, Win32, VMS)
1041 =item setpriority WHICH,WHO,PRIORITY
1043 Not implemented. (S<Mac OS>, Win32, VMS)
1045 =item setsockopt SOCKET,LEVEL,OPTNAME,OPTVAL
1047 Not implemented. (S<Mac OS>, Plan9)
1049 =item shmctl ID,CMD,ARG
1051 =item shmget KEY,SIZE,FLAGS
1053 =item shmread ID,VAR,POS,SIZE
1055 =item shmwrite ID,STRING,POS,SIZE
1057 Not implemented. (S<Mac OS>, Win32, VMS)
1059 =item socketpair SOCKET1,SOCKET2,DOMAIN,TYPE,PROTOCOL
1061 Not implemented. (S<Mac OS>, Win32, VMS)
1063 =item stat FILEHANDLE
1069 mtime and atime are the same thing, and ctime is creation time instead of
1070 inode change time. (S<Mac OS>)
1072 device and inode are not meaningful. (Win32)
1074 device and inode are not necessarily reliable. (VMS)
1076 =item symlink OLDFILE,NEWFILE
1078 Not implemented. (Win32, VMS)
1082 Not implemented. (S<Mac OS>, Win32, VMS)
1086 Only implemented if ToolServer is installed. (S<Mac OS>)
1088 As an optimization, may not call the command shell specified in
1089 C<$ENV{PERL5SHELL}>. C<system(1, @args)> spawns an external
1090 process and immediately returns its process designator, without
1091 waiting for it to terminate. Return value may be used subsequently
1092 in C<wait> or C<waitpid>. (Win32)
1096 Only the first entry returned is nonzero. (S<Mac OS>)
1098 "cumulative" times will be bogus. On anything other than Windows NT,
1099 "system" time will be bogus, and "user" time is actually the time
1100 returned by the clock() function in the C runtime library. (Win32)
1102 =item truncate FILEHANDLE,LENGTH
1104 =item truncate EXPR,LENGTH
1106 Not implemented. (VMS)
1112 Returns undef where unavailable, as of version 5.005.
1116 Only the modification time is updated. (S<Mac OS>, VMS)
1118 May not behave as expected. (Win32)
1122 =item waitpid PID,FLAGS
1124 Not implemented. (S<Mac OS>)
1126 Can only be applied to process handles returned for processes spawned
1127 using C<system(1, ...)>. (Win32)
1132 =head1 AUTHORS / CONTRIBUTORS
1134 Chris Nandor E<lt>pudge@pobox.comE<gt>,
1135 Gurusamy Sarathy E<lt>gsar@umich.eduE<gt>,
1136 Peter Prymmer E<lt>pvhp@forte.comE<gt>,
1137 Tom Christiansen E<lt>tchrist@perl.comE<gt>,
1138 Nathan Torkington E<lt>gnat@frii.comE<gt>,
1139 Paul Moore E<lt>Paul.Moore@uk.origin-it.comE<gt>,
1140 Matthias Neercher E<lt>neeri@iis.ee.ethz.chE<gt>,
1141 Charles Bailey E<lt>bailey@genetics.upenn.eduE<gt>,
1142 Luther Huffman E<lt>lutherh@stratcom.comE<gt>,
1143 Gary Ng E<lt>71564.1743@CompuServe.COME<gt>,
1144 Nick Ing-Simmons E<lt>nick@ni-s.u-net.comE<gt>,
1145 Paul J. Schinder E<lt>schinder@pobox.comE<gt>,
1146 Tom Phoenix E<lt>rootbeer@teleport.comE<gt>,
1147 Hugo van der Sanden E<lt>h.sanden@elsevier.nlE<gt>,
1148 Dominic Dunlop E<lt>domo@vo.luE<gt>,
1149 Dan Sugalski E<lt>sugalskd@ous.eduE<gt>,
1150 Andreas J. Koenig E<lt>koenig@kulturbox.deE<gt>,
1151 Andrew M. Langmead E<lt>aml@world.std.comE<gt>,
1152 Andy Dougherty E<lt>doughera@lafcol.lafayette.eduE<gt>,
1153 Abigail E<lt>abigail@fnx.comE<gt>.
1155 This document is maintained by Chris Nandor.
1159 Version 1.23, last modified 10 July 1998.