I want to recursively access class variable in a series of classes, like this:
use strict;
package Base;
our %types = qw/BASE_TYPE Some::Class/;
sub get_type {}
package Foo;
our @ISA = qw/Base/;
our %types = qw/FOO_TYPE Another::Class/;
package Bar;
our @ISA = qw/Base/;
our %types = qw/BAR_TYPE Yet::Another::Class/;
# what I want:
# get: BASE_TYPE => Some::Class,
# FOO_TYPE => Another::Class
my %foo_type = Foo->get_type();
# get: BASE_TYPE => Some::Class,
# BAR_TYPE => Yet::Another::Class
my %bar_type = Bar->get_type();
What I actually want is to simulate the sugar in actionscript's EventDispatcher, which can register type string with classes of event object, and derived dispatcher own all registered things from its parents recursively.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.