On Sun, Nov 27, 2022 at 08:49:29AM +0800, Host Cache wrote: > On 2022-11-21 23:16, Xinhuan Zheng wrote: > > Hi All, > > > > We need to migrate our codebase from mod_perl 1.0 to 2.0. In our > > codebase, we have used “use Apache::Constants”. We want to change > > it to be like: > > https://perl.apache.org/docs/2.0/user/porting/compat.html#mod_perl_1_0_and_2_0_Constants_Coexistence > > [1]. Our codebase are not only used in mod_perl environment, they are > > also used in Non mod_perl environment, like standalone program calling > > the modules in codebase. What should we change for “use > > Apache::Constants” in Non mod_perl environment? > > > > That's impossible. Apache::* modules are for modperl only.
You can send the program to either the mod_perl2 modules when mod_perl is running. Otherwise, you can use non-mod_perl modules when it's not. Most of the code can probably be left unchanged with a little luck. It depends a lot on how complex or exactly what is needed, but there are many options. CGI::Compile, for example could add that mod_perlish sort of effect. I was very tempted to learn a new framework when I had to change from version 1 over to 2, but it was really much easier for me to make a few code changes in lots of files rather than start from scratch. I actually ended up with better code after fixing those little bugs that were not worth the effort when writing it originally. -- Chris Bennett