Answering my own question:

Stas Bekman wrote:
When running:

modperl-2.0/ModPerl-Registry> t/TEST perlrun_require

I get

Subroutine whatever redefined at .../t/cgi-bin/lib.pl line 2.

warnings. I know why do we get this warning, but I fail to shut it down by adding: no warnings 'redefine' in t/cgi-bin/perlrun_require.pl:

Index: t/cgi-bin/perlrun_require.pl
===================================================================
RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/t/cgi-bin/perlrun_require.pl,v
retrieving revision 1.1
diff -u -r1.1 perlrun_require.pl
--- t/cgi-bin/perlrun_require.pl 6 Jan 2003 10:42:38 -0000 1.1
+++ t/cgi-bin/perlrun_require.pl 19 Dec 2003 02:12:08 -0000
@@ -6,7 +6,11 @@
my $vars = Apache::Test::config()->{vars};
my $require = catfile $vars->{serverroot}, 'cgi-bin', 'lib.pl';


-require $require;
+# ModPerl::PerlRun resets %INC, after compiling the script
+{
+    no warnings 'redefine';
+    require $require;
+}

the reason for 'redefining' warnings:


subs redefined inside the required file w/o a package declaration, were redefined inside the main:: package. so while perlrun was flushing the virtual (per-script) namespace it wasn't (and is not) flushing the main:: namespace.

the reason for not being able to shutdown those warnings, is that the 'warnings' pragma doesn't affect required files. Could have used $^W, but then it'll affect the scripts which may have wanted to have warnings on, relying on the server global (PerlWarn On|-w). So users will have to shutdown those warnings themselves if they get any.

the only remaining problem is constants which you can't shutdown. But again, perlrun can't do much about it and probably shouldn't.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to