Tony - There are lots of people using Registry successfully (in fact the
new Bugzilla uses Registry, if I remember correctly).
> Thank you, Jonathan, for your more detailed explanation. I have to say, I am
> extremely disappointed with my experience. I've used PHP for some years to
> create interactive web sites with some success, but having read about the
> significant performance boost available from mod_perl, I bit the bullet, and
> used PERL for the first time on my current project. Had I known then what I
> know now, I wouldn't have bothered :-(
>
> I don't even like the language much, but I'm sure that's a personal thing.
Give it time. I'm maintaining some PHP code, and all I want to do is
rewrite it in Perl.
>
> It looks then like I have two options:
> 1. abandon mod-perl and just use cgi.
> 2. move the project to a server over which I have full control.
>
> (1) rather defeats the object of using PERL, and I am loth to acknowledge
> defeat; (2) adds significant expense, and extra effort, to the project. Bah
> - what a mess!
I think that Jonathan is exaggerating the risks, and if you don't have
the luxury of running your own server then it is quite acceptable to use
these modules. See here for some points about the trade-offs that you
make :
http://search.cpan.org/~pgollucci/mod_perl-2.0.3/docs/api/Apache2/Reload.pod#Performance_Issues
I have little exposure to it, but from reading these lists over the last
decade, and reading the docs for Apache2::Reload, ModPerl::Registry etc,
I think that Registry is a perfectly usable product, with a couple of
gotchas.
I would welcome feedback on the experiences of others.
The biggest gotchas are:
* GLOBAL VARIABLES
In a CGI script, maybe you have:
our $var;
$var = 'xx' if $flag;
But because Registry scripts are persistent, variables that
haven't been properly intialiased, may contain data from
previous requests.
So instead write:
my $var;
OR
our $var = undef;
* CLOSURES : you can't do this:
my $var;
sub my_sub {
print $var;
}
... because Registry loads this script as:
sub handler {
my $var;
sub my_sub {
print $var
}
}
which will give you the warning: $var will not stay shared
Instead, do this:
sub my_sub {
my $var = shift;
print $var
OR
our $var = undef;
sub my_sub {
print $var;
* CHDIR
chdir is not thread safe, and cannot be relied upon, and the
current working dir is not reset for each call to a script.
Instead use absolute paths (plus use lib '/path');
* IMPORTING FROM MODULES / BEGIN/CHECK/END BLOCKS
If a Registry script imports subs/variables from a use'd module,
and the module is reloaded - the imported sub isn't updated. This
is because the 'use' statement executes on the first compile, and
not subsequently.
So instead of:
use MyModule qw(sub1 sub2);
Do:
require MyModule;
MyModule->import(qw(sub1 sub2));
Read more about the BEGIN/CHECK/END blocks issue here:
http://search.cpan.org/~pgollucci/mod_perl-2.0.3/docs/api/Apache2/Reload.pod#Caveats
Other than that, Registry works well. There will be edge cases where
Perl modules are doing some dark magic, which may have unexpected side
effects, but for the most part, it should all just work.
Clint
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.