mgraham ([EMAIL PROTECTED]) said something to this effect:
> With the above I expect to be able to call the following in some
> handler:
> 
>     Foo::load_var()
> 
> ...and $PACKAGE_LEXICAL should still be 'wubba'.

...Except that by calling Foo:load_var() you are setting $PACKAGE_LEXICAL
to undef (by passing in an empty list via ()), rather than retrieving it.
You should do something like:

package Foo;

{ # Block scope this stuff just to ensure that no other subroutine besides
  # var can modify $PACKAGE_LEXICAL.
    my $PACKAGE_LEXICAL;
    sub var {
        return
          (@_)
            ? $PACKAGE_LEXICAL = shift
            : $PACKAGE_LEXICAL;
    }
}

# More of package Foo here...
1;

This will set $PACKAGE_LEXICAL if you pass something in, and return it, or
just return it otherwise.  Each child will have its own $PACKAGE_LEXICAL.

(darren)

-- 
All things are possible, except for skiing through a revolving door.

Reply via email to