If you're developing a complex application, you'll probably want to split it in a horde of specialized modules. Few things to remember:
== You will probably feel the need to use static variables (i.e. variables shared with all instances of a given class) at some point. For example if you have a singleton object you might have something like that: package Your::Singleton; use strict; use 5.6; use our $ETERNAL = undef; sub instance { my $class = shift; return $ETERNAL if (defined $ETERNAL); $ETERNAL = $class->new (@_); return $ETERNAL; } sub new { ... blah blah code ... } 1; ALWAYS reinitialize $Your::Singleton::ETERNAL on each query! mod_perl will *NOT* do it for you. You might think 'ah yeah but it would be nice if $Your::Singleton::ETERNAL could be persistent across queries...' which is sometimes desirable, but remember that if you have multiple instances of your application running on the same apache, $Your::Singleton::ETERNAL will be common to ALL of them. == Cyclic memory references are dangerous, try to avoid them as much as possible! Perl garbage collector does miserably fails in the case of cyclic refs. If you have a cycling references that keep going out of scope, they will never be garbage collected and your server might have some trouble :-) == Beware of regular expressions /o modifier! The application I'm working on has a cool feature heavily using regular expressions: automagic hyperlinking of text / html data when appropriate. I used to use the /o modifier and got a few nasty surprises (until I discovered the mod_perl guide traps page) == Other than that, more generally speaking: Always hide classes implementation with method calls! Not so long ago I did tend to write using less method calls and directly accessing object's attributes and now this is my #1 source of maintenance problem and headaches. It you think it's too slow then consider it's better to buy a bigger CPU than 3 tons of aspirin. Also avoid using packages names inside functions as much as possible, as it tends to screw inheritance. Finally my biggest piece of advice: ENFORCE a coding style. ENFORCE using english for variable, function names and comments (for example although I'm French I really can't stand code written with french variable names and comments! The Perl language is using English keywords after all. Be consistent FFS) . ENFORCE commenting what every single method does. Having said that I do naturally tend to write awful code that only I can understand, but at least everything is properly commented :) Cheers, -- IT'S TIME FOR A DIFFERENT KIND OF WEB ================================================================ Jean-Michel Hiver - Software Director [EMAIL PROTECTED] +44 (0)114 221 4968 ================================================================ VISIT HTTP://WWW.MKDOC.COM