> -----Original Message-----
> From: Marc Lehmann [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 25, 2000 9:57 PM
> To: Doug MacEachern
> Cc: [EMAIL PROTECTED]
> Subject: Re: global variables and reparsing question (low priority ;)
>
>
> On Thu, May 25, 2000 at 11:58:38AM -0700, Doug MacEachern
> <[EMAIL PROTECTED]> wrote:
> > > You must be kidding here!!! Using lexicals on package
> level is broken??? If
> > > it is broken, then _why_ is it recommended programming
> practise in perl (see
> > > perltoot for example)?
> >
> > i'm not kidding. i don't understand whay you mean by
> 'using lexicals on
> > package level is broken'.
>
> here is my module, in very terse pseudocode:
>
> ==============================================================
> ===============
> package mymodule;
>
> my some"globals";
>
> sub functiousing someglobals {
> }
>
> now load other code (in some kind of xml) and compile it into it's
> package, UNLESS the package already exists.
> ==============================================================
> ============
>
> And this obviously breaks for the newly compiled code. The caching,
> unfortunately, is very important. Surely I could make an
> exception when
> running under mod_perl with PerlFreshRestart, but that code
> runs nicely in
> other environments, since the apache bits have been
> abstracted away. Read
> below.
mod_perl sometimes requires special perl coding guidelines, due in part to
the way mod_perl works with and within apache.
For example, you shouldn't do things under Registry that are otherwise ok
and 'run nicely in other environments' like plain cgi - a fact that is well
documented and understood and, in the end, appreciated by the people who use
mod_perl. that doesn't make mod_perl a dialect of perl, it's just the
result of how Registry works. It's the same with PerlFreshRestart - you
can't separate mod_perl from the apache application environment which has
specific restart behaviors.
>
> > and, like i said, i realize that certain modules make
> assumptions that
> > they will only be loaded once in the same process and that
> re-parsing them
> > can uncover subtle problems. but i still consider such
> assumptions to be
> > broken.
>
> Sorry, but reparsing is never done by perl itself (it
> explicitly says so),
> so mod_perl clearly is not acting like perl.
>
> So, in in the mod_perl dialect of perl, modules that work fine in perl
> magically break on restarts.
> This is because mod_perl "restarts" by
> fooling the perl interpreter to think it hasn't seen _some_
> parts of the
> program(s) and tries to reload all on top of it.
>
> What's confusing here is the term "FreshRestart", which doesn't do
> anything like a "fresh restart".
actually, it makes perfect sense, if you think of it in apache/mod_perl
terms and not just perl. you can issue a restart in apache, and for apache
your httpd.conf file is re-read and the changes applied. however, your
modules will not be re-read and, thus, any changes will not be applied.
Hence PerlFreshRestart On attempts to make a mod_perl enabled apache behave
the way you intuitively want it to - reloading all the changes you just made
to httpd.conf and the modules that affect the way your apache environment
behaves. It's a good idea that can, however, have some consequences. and,
just like Registry, requires special coding attention should you choose to
take advantage of it.
>
> The reason this is important to me is not because I couldn't make an
> exception to my code for apache - it's the real world, so hacks are
> necessary in many cases anyway - but because what's broken is
> mod_perls
> idea of "fresh restarting" by cheating the perl interpreter
> rather than my
> code.
>
> Now that I know what's going on it's not a big deal, but if you call
> my code broken you should have rather good arguments on the basis of
> the perl language and protgramming, not because mod_perl does
> some very
> undocumented things differently to perl itself.
http://perl.apache.org/guide/troubleshooting.html#Evil_things_might_happen_w
hen_us
http://perl.apache.org/guide/config.html#Apache_Restarts_Twice_On_Start
perldoc mod_perl
the Eagle book
the mod_perl list archives
I've seen references to each of these in this and your related threads - the
documentation is there, you just have to take the time...
and, there's no reason to get real argumentative or defensive about any of
this, Marc - we're all friends here, in modest persuit of the same things :)
--Geoff
>
> --
> -----==- |
> ----==-- _ |
> ---==---(_)__ __ ____ __ Marc Lehmann +--
> --==---/ / _ \/ // /\ \/ / [EMAIL PROTECTED] |e|
> -=====/_/_//_/\_,_/ /_/\_\ XX11-RIPE --+
> The choice of a GNU generation |
> |
>