> Sorry if this has been mentioned before or I'm teaching you to suck eggs,
> but if you are running an old CGI script in mod_perl you need to not scope
> with 'my'.
>
> See
> http://perl.apache.org/docs/general/perl_reference/perl_reference.html#my___
> _Scoped_Variable_in_Nested_Subroutines
This is not a global rule: "do not use 'my' for any variables". You
should still use 'my' for most variables.
What you must be careful NOT to do is to avoid using 'my' variables in a
subroutine where it has not been declared.
For instance:
---------------------
sub foo {
my $this_is_ok;
....
return $this_is_ok;
}
---------------------
---------------------
my $this_is_not_ok;
sub bar {
$this_is_not_ok++;
}
---------------------
That is because this last example, when used in Registry, becomes this:
---------------------
$myscript = sub {
my $this_is_not_ok;
sub bar {
$this_is_not_ok++;
}
}
---------------------
which creates a closure, with its own private copy of $this_is_not_ok -
you will see "Variable will not remain shared" warnings in your logs
(assuming you have strict or warnings turned on - I forget which)
HTH
Clint