Ok, I am not interestd in relying on globals like I was, but I did stuble on esomething, and after reading the documentation, I am a bit confused as to what I did.
I wanted to be able to get access to: my $r = Apache->request; inside two different modules and the error log told me to turn on "PerlOptions +GlobalRequest", which I did, and it allowed me to have access to Apache->request everywhere. The thing is that it also fixed my globals so that on every reload of the page they are set back to their original values instead of incrementing. I'm geuessing that +GlobalRequest is something that I should avoid using, since it seemed that the consensus is that globals are bad. What does GlobalRequest do exactly, and is there a better way to get Apache->request in modules? Thanks, Nathan On Thu, 27 May 2004, Nathanial P. Hendler wrote: > > I'm not sure if this is a style or function question. I'd like to have a > module called Debug.pm that has a variable in it that if set to '1' by > anything (main script, or other modules) will print debug messages. > > Reading the Orielly "Practical mod_perl" I thought it was clear what I > needed to do, but I am finding it difficult. The following works as one > file, but when I break the Debug part into its own file, the value of $D > just increments with every re-load... > > #!/usr/local/bin/perl > > use strict; > use warnings; > use CGI qw(:standard); > use Debug; > > print header(); > > Debug::report('I should not see this line'); > $Debug::D++; > Debug::report('I should see this line'); > $Debug::D++; > Debug::report('This one too'); > > package Debug; > use strict; > use warnings; > > use vars qw($D); > $D = 0; > > sub report { > my $string = shift; > > print "DEBUG ($D): $string<br>\n" if $D; > } > > 1; > > > Can anyone explain to me why I can't have a global variable when I put > Debug into its own file? > > Can anyone tell me how to accomplish what I'm after? > > Thanks, > Nathanial Hendler > Tucson, AZ USA > http://retards.org/ > > > -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html