in reply to Package Variables in Inheritance

It's not clear what you're after here. If you want actual inheritable class data, you should use Class::Data::Inheritable. If you just want to access some globals in the parent class, you can fully qualify them as you did in your $Obj::Name example, but that's not inheritance. Your example using "our" is not inheritance either. It's just the same thing, with a lexically scoped alias for $Obj::Name. It only works because you have both packages in the same file.

The "SUPER" keyword only works on method calls. The way you used it, it just gets treated as the literal name of a package.

Replies are listed 'Best First'.
Re: Re: Package Variables in Inheritance
by reyjrar (Hermit) on Oct 31, 2003 at 20:15 UTC
    Cool. That makes me feel better. Basically, I know there are several ways to do this. The real code is a report writer. There are 3 variables I want to be able to change in a child class. Then I want to over load two function header() and footer() if necessary. Brain is fried, but basically, here's what I'm trying to accomplish.

    Base Class is the Report Writer. It doesn't care what its writing, it writes things. I want to inherit from it and change 3 variables, the sheetname, the header array (column names), and the fields hash (which is kinda cool, it knows how to extract each field from a generic hash which is used to generate 7 different reports). I'm lazy (this is why I love perl) and I wanted to basically do this:
    package Report::Writer::Test; use vars qw/@ISA/; @ISA=qw/Report::Writer/; $SheetName = "Test"; @HEADER = qw/I AM TESTING/; %Fields = ( I => sub { return uc $_[0]->{firscol} }, AM => 'secondcol', TESTING => 'PLACE HOLDER' );
    The end result, is based on my Report::Writer module, I wouldn't have to write anything else to make Report::Writer::Test work.

    broquaint's solution was what I was looking for. I'll investigate Class::Data::Inheritable to see if it does what I want it to do. Thank you for the suggestion.
    -brad..