in reply to How to implement such kind of magic?
Or do you want one hash in the base class, and populate it along the way? That might look like this:
use strict; use warnings; { package Base; our %types = qw/BASE_TYPE Some::Class/; sub get_type { $types{$_[0]} } } { package Foo; our @ISA = qw/Base/; $Base::types{FOO_TYPE} = q/Another::Class/; } { package Bar; our @ISA = qw/Base/; $Base::types{BAR_TYPE} = q/Yet::Another::Class/; } use Data::Dumper; print Dumper \%Base::types; print Base::get_type('BAR_TYPE'), $/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to implement such kind of magic?
by llancet (Friar) on Dec 03, 2009 at 00:52 UTC |