in reply to Using package variables dynamically

Well, generally, packages should keep their hands off of other packages' variables. It's considered unsafe. Instead, you could have (in each subclass) a class-level method which returns a reference to the desired "private" variable. E.g.
package my::model::subclass; . . . sub normal_hr { # because it returns a hashref \%normal } # then: package my::model; . . . sub use_subclass_package_var { my ($self, @cols) = @_; my $normal = $self->normal_hr; foreach my $col (@cols) { next unless exists $normal->{$col}; # the rest of the code } }
But I'm confused as to what you're really trying to achieve here. My gut instinct is that whatever it is, it's probably better done another way.

Replies are listed 'Best First'.
Re^2: Using package variables dynamically
by redhotpenguin (Deacon) on Feb 08, 2005 at 18:53 UTC
    Great idea. I should have kept in mind the principle of encapsulation when solving this problem. Thank you jdporter, and thanks chromatic.