Could someone tell me why constant is preferable to #define in the following code?
constant will work on platforms without cpp (that's the big one for me :-)
constant is package scoped. #define is not.
With constant you have access to perl at compile time. With #define you do not.
Different versions of cpp on different platforms do different things.
It's unlikely to be much faster, if at all. The constant's are expanded at compile time so there is no run-time cost using either system. Starting up a cpp process may actually slow down your compile time.
require() will include your code only once, compile in a separate lexical file scope, and in package main by default. #include will not.
Snippets of code should be wrapped in
<code> tags not<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor