If your scripts contain server-dependent code, that is, code
which is specific to a particular server, you would need to
rewrite code if you ever decided to move your site to a different
web server. One such occasion would be if you decided to upgrade
to or downgrade from a High Volume account, since these accounts
reside on high volume servers. Another occasion would be if you
ever decided to reuse your scripts for other accounts, or give
your scripts to other people. You should always try to write code
that will run correctly regardless of what web server it runs on.
The most common kind of server-dependent code is code which
accesses files or programs using an absolute path (such as
"/www26/web/someid/somefile"). Instead of using the
absolute path to your home directory
("/www26/web/someid"), you should instead use the
DOCUMENT_ROOT environment variable ($ENV{DOCUMENT_ROOT} in Perl)
to determine the path of your files or programs within a script.
For example, if a guestbook script reads:
# Path to your guestbook file
$guestbook = "/www23/web/examp9/data/guest.html";
You should change it to:
# Path to your guestbook file
$guestbook = "$ENV{DOCUMENT_ROOT}/data/guest.html";
If you are writing scripts for others besides yourself to use,
you may wish to take advantage of the many other environment
variables which allow you to write server-independent code.
(Note: if you are writing scripts or recipes for use with
procmail, you must use the HOME environment variable in place of
DOCUMENT_ROOT. CGI environment variables are not available while
running under procmail.)