[...]
OK, your last post's examples were more to the point of wanting to destroy objects at the end of the request, and hence here is a new summary:
- move the perl4 lib solution to the perl_reference.pod
- suggest turning a lexical variable declared with my() into a global variable declared with our() to avoid the closure, with the following "but"s:
o if with my() it wasn't crucial to initialize the variables (since my() initialized them to 'undef'), now all variables declared with our() must be explicitly initialized.
s/my $counter = 0/our $counter = 0/;
[Brian: notice that I prefer *not* to suggest using local() to init vars, and rather have users do that explicitly, which is a good practice]
o since the initialization of global variables happens at the beginning of the request, if a variable which contains an object:
my $query = CGI->new;
is made global:
our $query = CGI->new;
it won't be destroyed untill the next request. If you wish to make sure that it's destroyed at the end of the request, you must local()'ize the variable:
local our $query = CGI->new;
- users of perl < 5.6 have to use 'use vars' instead of 'our'. So the above examples become:
use vars qw($counter); $counter = 0;
and:
use vars qw($query); local $query = CGI->new;
- point to perl_reference.pod for other workarounds/solutions.
Please let me know if I have missed something from your last posts suggestions.
__________________________________________________________________ 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
-- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html