Hi.

I feel like I'm asking a lot of questions lately, but this list has
been extremely helpful. :)

I'm writing some packages that inherit from a base class, which has
some fields and some global variables that I want inherited.  I have
code like:
     # La/De/Da/MyBase.pm
     package La::De::Da::MyBase;
     .....
     use fields qw( MyField );
     use vars qw( %Attributes );
     %Attributes = ( 'a' => 1, 'b' => 2);

     # La/De/Da/MyPackage.pm
     package La::De::Da::MyPackage
     .....
     use base qw( La::De::Da::MyBase ); # Takes care of @ISA and %FIELDS.
     use vars qw( %Attributes );        # But also need vars.
     %Attributes = %La::De::Da::MyBase::Attributes;
     $Attributes{'c'} = 3;              # Extend the attributes hash

The 'use base' pragma nicely takes care of the @ISA and %FIELDS
variables for me, but I also need to have the package global variable
%Attributes inherited.  The 'use vars' and assignment in MyPackage is
rather verbose, and I'm wondering if there is a better or terser way
of doing that.  What's the recommended way of inheriting package
global variables?

+ Richard J. Barbalace

Reply via email to