Adee Ran - 2003-02-16

Logged In: YES
user_id=321578

I installed mod_perl on my machine (Win2K running Apache
2) and tested that it's working. It can be a testbed for chiq.pl.

After reading
http://perl.apache.org/docs/1.0/guide/porting.html I think
chiq_chaq cannot be run currently under the Registry mode
(maximum boost, by leaving the script in memory). It may
run under the PerlRun mode which leaves just the Perl
interpreter in memory - but may leak memory over time.

For now, I identified the following issues:

- Nested subroutines: in Registry mode, chiq.pl is executed
from within an external subroutine (handler()) . Therefore,
named subs inside it are nested subs, and they cannot
modify file-scoped variables (declared either my or our). This
can be identified by a warning written to the error log.
=> remedy: move all subs and variables to a module (e.g.
chiqmain.pm), and execute only a call to main() in the chiq.pl
script.

- Namespace - The script's namespace under mod_perl is not
main:: or ::. Modules that access 'global variables' should be
corrected.

- File handle leakage: files must be closed after each
invocation. however, if closed explicitly by close FH, the
script may abort (e.g. user clicked 'stop' in browser) and
close will not be executed.
=> remedy: use IO::File to store filehandles in scalar
variables (Perl 5.6 can do it natively). Make them lex scoped
('my'). They will always go out of scope and be closed.

- Global (our) variables are persistent - they must be re-
initialized per request. Perl special variables are always
global.
=> remedy: use 'my' variables, and localize specials.

- -M and other file-time tests: results are relative to first perl
invocation.
=> remedy: localize $^T or use stat().

- /o regexp modifier: all regexps that are 'set once' will not be
recompiled for each invocation. This means that they should
not depend on invocation parameters (CGI parameters,
cookies, etc.)

- @INC - is global to mod_perl and cannot be changed. Also,
namespaces may clash with other scripts.

- Config files - re-configuring can be bypassed if last run was
from same file and the file was not changed.

- exit() should not be used. use Apache::exit (Perl 5.6 does
this automagically).