Michael Kraus <[EMAIL PROTECTED]> wrote:

: What I was trying to achieve with this:
:
: --START--
: our %InheritableClassData = (
:   DBH => undef,
:   Q => undef,
:   Handler => undef,
: );
:
: foreach (qq(DBH Q Handler)) {
:   sub $_ {
:       shift;
:       $InheritableClassData{$_} = shift if @_;
:       return $InheritableClassData{$_};
:   }
: }
: ---END---
:
: Was really just an attempt at a shorthand version of:
:
: --START--
: our %InheritableClassData = (
:   DBH => undef,
:   Q => undef,
:   Handler => undef,
: );
:
: sub DBH {
:   shift;
:   $InheritableClassData{DBH} = shift if @_;
:   return $InheritableClassData{DBH};
: }
:
: sub Q {
:   shift;
:   $InheritableClassData{Q} = shift if @_;
:   return $InheritableClassData{Q};
: }
:
: sub Handler {
:   shift;
:   $InheritableClassData{Handler} = shift if @_;
:   return $InheritableClassData{Handler};
: }
: ---END---

    Perhaps you missed the solution I provided. It should provide
the methods you have above.

[snip]
: : foreach my $method ( keys %InheritableClassData ) {
: :     no strict 'refs';
: :     *$method = sub {
: :         shift;
: :         $InheritableClassData{$_} = shift if @_;
: :         return $InheritableClassData{$_};
: :     };
: : }
[snip]

: Should I be using "my" or "our" here for the variables - these
: are the variables I want present in all my derived classes and
: should be the same for all.

    I don't know. I would play with each using multiple object
instances to be sure which is right. I am leaning more toward
'my', but I just don't know.


HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to