That should be fine, although the assignment of
$sub looks broken as the calling object doesn't have the
$m method defined (unless the
$m method is created in the
AUTOLOAD call), otherwise
AUTOLOAD wouldn't have been called. Also unless you're doing something really clever with
$m that will loop forever as the calling object has
AUTOLOAD defined, and without the
$m method defined
$sub will always end up pointing to the
AUTOLOAD method and calling itself in the
goto. Here's my take on
AUTOLOADing methods
sub AUTOLOAD {
no strict;
(my $m = $AUTOLOAD) =~ s{.*::}();
*$m = make_method_here()
if $m =~ /fulfils some condition/;
croak "AUTOLOAD: can't access method $m";
unless defined *$m{CODE} and $_[0]->can($m);
goto &$m;
}
But as far as calling goto with a method name having left @_ intact, that nicely emulates a method call. The drawbacks would be that it'll be slow, and it's always a bit contentious dynamically creating/accessing methods via AUTOLOAD when quite often the likes of Class::Accessor will suffice (but as always, it's somewhat of a rule-of-thumb decision).
HTH
_________
broquaint
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.