The eval was inherited (in the older meaning of the term) from the predecessor package, which was written in 1998. I've happily changed the second-last code line to
*$AUTOLOAD = sub{$val};. In the next statement, I forgot that the object of using a constant name was to get the constant's value, which is why the goto is needed. I may be getting too old for this.
I was not familiar with "God module/antipattern" terminology. Having been in programming since '63 I value modularity highly, and would never create/architect a module like the one I'm working to replace.
But having inherited (in the classic sense) a bloated package, and knowing how much compatibility means to many people, at the moment I'm keeping compatibility. Not that the older package probably has many users: the problems I know about probably preclude that.
On the other hand, having 8 packages inherit from XYZ::ABC may be OK this once, seeing as the only thing "in" each package is a
1;.
Last question for now: to pursue the compromise course, my instantaneous version of this AUTOLOAD contains:
my $subname = lc($mmx) . '_' . lc($sah) . '_' . lc($fu
+nction);
*$AUTOLOAD = sub {
my $base_sah_ref = shift;
# dereference the base "sah"
unshift @_, $$base_sah_ref;
goto &$subname; # or &{*$subname{CODE}} ??
};
goto &$AUTOLOAD;
Is Perl smart enough to capture the current value of $subname in the anonymous sub, rather than use a reference to a local variable that will soon go away? Is this one of those "reference count" things wherein perl is superior to C?
cmac
www.animalhead.com
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.