Listing 2.
Keeping your code portable to MacPerl
Matthias Neeracher

"Casting Perl before Macintoshes"
The Perl Journal, Summer 1996
  Most Perl code can be ported to MacPerl with a few minor adjustments, and in fact even those are often not necessary if authors follow a few guidelines:

  • Do not assume that \n and \012 are identical, and do not use them indiscriminately: Text files should follow the conventions of the host system, so lines should be terminated with \n. Data in network protocols (Telnet, HTTP, SMTP) follows a host independent standard, so lines should be terminated with hard coded characters, usually \015\012.
  • Do not assume that path components are separated with '/', nor that several path separators in a row mean the same as one. Use libraries like File::Basename to avoid dependencies on path name syntax.
  • Minimize the use of system(), pipes, and backquotes. Use libraries like Cwd and File::Copy instead.
  • Keep your build and installation systems as portable as possible. Rely on MakeMaker's built-in features and avoid hardcoding pieces of UNIX Makefiles into your Makefile.pl.
  • Do not assume that system time is measured from January 1, 1970.