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