[Mpls-pm] Indirect reference/inheritance?
Peter Karman
peter at peknet.com
Wed May 24 14:03:58 PDT 2006
Was reading about this just yesterday here:
http://perldoc.perl.org/perlbot.html
See especially the section "CLASS CONTEXT AND THE OBJECT."
The recommendation is to always put a reference to package vars in the
object itself, to avoid the kind of problem you're experiencing.
[ I realize this kind of response is annoying (e.g., "why don't you do
it this way instead...") but as I am only the messenger, please don't
shoot. ;) ]
Chris scribbled on 5/24/06 2:45 PM:
> Okay, I have 2 classes, one being a subclass of the other.
>
> package A
>
> sub foo {
> return;
> }
>
> package B
> use base(A);
>
>
> Package A has a subroutine that *should* manipulate a variable in the
> namespace of the involking object.
>
> That is, if B is a subclass of A, and B has %Foo, the subroutine in A
> should manipulate %B:Foo.
>
> However, my attempt at an indirect reference is failing.
>
> $class=ref($object)
> $var=$class."::Foo";
>
> foreach $k (keys(%{$var}))
> {
> # do stuff
> }
>
> I'm stuck with perl 5.8.0 on this one.
>
> Any ideas what I'm screwing up?
>
> --------------------
> Christopher Josephes
> cpj1 at visi.com
> _______________________________________________
> Mpls-pm mailing list
> Mpls-pm at pm.org
> http://mail.pm.org/mailman/listinfo/mpls-pm
>
--
Peter Karman . http://peknet.com/ . peter at peknet.com
More information about the Mpls-pm
mailing list