The Basic of mod_perl Support

Max Kanat-Alexander mkanat at bugzilla.org
Mon Jun 19 13:26:09 UTC 2006


On Mon, 2006-06-19 at 15:44 +0300, Dennis Melentyev wrote:
> Could you please also tell us, what other things we should know to make
> code compatible with mod_perl? I mostly mean common mistakes and good
> code patterns/practices.

	The rule I said below pretty much covers it. You just have to imagine
that you're re-using the same compiled module over and over.

	For example, let's pretend that your module looks like this:

	package Foo;

	my $user = Bugzilla->user;

	First time you load the page, $user will be correct. Second time,
somebody else loads the page, the $user variable won't even exist. Why?
Because "my" puts something in the scope of the currently-running
script.

	In general, it's just not a good idea to ever have code execute outside
of a subroutine, in a .pm file. If you follow that rule, you'll be safe.
There are some exceptions, but don't worry about it unless you *reall*
have to. Just put everything in a subroutine.

> Or, just point me to some good docs on mod_perl.

	This is for mod_perl 1.x, and we're going to be using 2.x, but the
ideas are basically the same:

	http://perl.apache.org/docs/1.0/guide/porting.html

	-Max
-- 
http://www.everythingsolved.com/
Everything Solved: Competent, Friendly Bugzilla and Linux Services




More information about the developers mailing list