in reply to Need help migrating functionality from subclass to super class

I'm not sure I'm completely clear on what you're looking for. In particular, I think your last <code> block probably ought to be different since you declare the same package twice.

One thing you could do is have the subclass pass references to its our variables to the superclass at some point. If you don't want to change anything in the subclass, maybe some part of the superclass could use caller to see where a call is coming from, but I don't know that you can get access to the subclass's variables that way.

As I was reading, I kept thinking maybe you could tie those variables to some package that would do whatever twisty thing you want to do. Something like:

package MyApp::Mistake; my $destination; sub TIEHASH { ... } sub STORE { my ($self, $key, $value) = @_; $destination->{$key} = $value; } sub set_destination { $destination = $_[1] } package MyApp::PageController; my %URI_enabled; MyApp::Mistake->set_destination( \%URI_enabled );

That could maybe work, but it seems like a lot of voodoo.

Replies are listed 'Best First'.
Re^2: Need help migrating functionality from subclass to super class
by 2xlp (Sexton) on May 03, 2007 at 18:01 UTC