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