"Before I delve into the details of mod_perl programming in
the future articles it's probably a very good idea to review some
very important Perl basics. You will discover these invaluable when
you start coding for mod_perl. I will start with pure Perl
notes and gradually move to explaining the peculiarities of coding
for mod_perl, presenting the traps one might fall into and
explaining things obvious for some of us but may be not for the
"It helps when you code your application in a structured way,
using the perl packages, but as you probably know once you start
using packages it's much harder to share the variables between the
various packagings. ... Of course, using object-oriented (OO)
programming is the best way to provide an access to variables
through the access methods. But if you are not yet ready for OO
techniques you can still benefit from using the techniques I'm
going to talk about."
"Special Perl variables like $| (buffering),
$^T (script's start time), $^W (warnings
mode), $/ (input record separator), $\
(output record separator), and many more are all true global
variables; they do not belong to any particular package (not even
main::) and are universally available. This means that
if you change them, you change them anywhere across the entire
program; furthermore you cannot scope them with my().
However you can local()ise them which means that any
changes you apply will only last until the end of the enclosing
scope. In the mod_perl situation where the child server doesn't
usually exit, if in one of your scripts you modify a global
variable it will be changed for the rest of the process's life and
will affect all the scripts executed by the same process.
Therefore, localising these variables is highly recommended, I'd
"When using a regular expression that contains an interpolated
Perl variable, if it is known that the variable (or variables) will
not change during the execution of the program, a standard
optimization technique is to add the /o modifier to
the regex pattern. This directs the compiler to build the internal
table once, for the entire lifetime of the script, rather than
every time the pattern is executed."
Some of the products that appear on this site are from companies from which QuinStreet receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. QuinStreet does not include all companies or all types of products available in the marketplace.