Perrin Harkins wrote:

To summarize:

- move the perl4 lib solution to the perl_reference.pod
- suggest replacing my() with our() to avoid the closure, however this change requires that the variables will be initialized before used in most cases (example of 'open our $foo' which doesn't need to be initialized). you can initialize variables by an explicit assignment of the value, or using the 'local our' trick, which will initialize the variable to under, which is probably not what you want.
- for users of perl < 5.6 suggest to use 'use vars' instead of 'our'.
- point to perl_reference.pod for other workarounds/solutions.


May I also suggest telling users to pass arguments explicitly to subs,
instead of doing it implicitly?  Nearly all of the Registry-related bugs
I see stem from people doing this:

my $cgi = CGI->new();

foo()

sub foo {
  $cgi->param(whatever)...
}

They accidentally create a closure this way and then wonder why their
form values never change.  Passing $cgi to foo() fixes the problem.

We have that already covered in perl_reference.pod, example multirun3.pl. Originally all the workarounds were in the porting.pod but then there were too many of them. so I thought to give just one solution and a pointer to a document/section with the rest of the solutions. If you think it's worth mentioning it in porting.pod in addition to the current place, feel free to adjust it. Your above example prabably more familiar to cgi script writers, than an abstract $counter exapmle.


Thanks!

__________________________________________________________________
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



Reply via email to