Porter Efficiency
Wave a handsome tip under his nose.
Avoid functions that aren’t implemented everywhere. You can use
evaltests to see what’s available.Use the
Configmodule or the$^Ovariable to find out what kind of machine you’re running on.Put in
use v5.xxstatements in to denote the Perl you need.Don’t use new features just to play with shiny things.
Don’t expect native float and double to
packandunpackon foreign machines.Use network byte order (the “
n” and “N” formats forpack) when sending binary data over the network.Don’t send binary data over the network. Send ASCII. Better, send UTF-8. Better yet, send money.
Use standard or common formats, such as JSON or YAML, for language- or service-agnostic data exchange.
Check
$]or$^Vto see whether the current version supports all the features you use.Don’t use
$]or$^V. Userequireorusewith a version number.Put in the
eval exechack, even if you don’t use it, so your program will run on those few systems that have Unix-like shells but don’t recognize the#!notation.Put the
#!/usr/bin/perlline in even if you don’t use it.Test for variants of Unix commands. Some find programs can’t handle the –xdev switch, for example.
Avoid variant Unix commands if you can do it internally. Unix commands don’t work too well on MS-DOS or VMS.
Put all your scripts and manpages into a single network filesystem that’s mounted on all your machines.
Publish your module on CPAN. You’ll get lots of feedback if it’s not portable.
Make it easy for people ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access