Search code examples
perloopmodulemod-perl2

Is "local our" the thing to use in object modules under mod_perl2, or only in scripts?


To tailor your scripts toward mp2, avoiding the need for any compatibility wrappers and such, it's said that you're supposed to declare variables using "local our" rather than "my". What about in modules?

sub new
{
    local our $type = shift;
    local our $self = {};
    bless $self, $type;
}

Is that right? Or should it be 'my' so the rest of the module can get at $self under "use strict"?


Solution

  • You definitely need my.

    The local our advice pertains to variables that are global in your module.