[Mpls-pm] Indirect reference/inheritance?

Ken Williams ken at mathforum.org
Wed May 24 13:37:55 PDT 2006


On May 24, 2006, at 2:45 PM, Chris wrote:

> However, my attempt at an indirect reference is failing.
>
> $class=ref($object)
> $var=$class."::Foo";
>
> foreach $k (keys(%{$var}))
> {
> 	# do stuff
> }

Hi Chris,

You didn't say how it's failing, but I'm guessing $class here isn't  
what you think it is.  Try printing out the value of $class or $var  
in a debug message.

Perhaps you want $class = $ISA[0] instead of $class = ref($object).   
Keep in mind that $object could be essentially any arbitrary subclass  
of B or A, and caring about its class name is Officially Evil.

If that debug message doesn't shed light, try posting a full example  
with the error messages you're getting.

  -Ken



More information about the Mpls-pm mailing list