Hi Jesse,
>
> Didn't anyone ever tell you not to look upder the hood? Hehe...
>
Yeah, but I never learn!
> I think the name for what I've done here is "Perl obfuscametrics". It's a
> dirty, evil hack -- but it sure looked nicer than:
>
> $rm = &{$rm_param}($self);
>
> What you have here is actually a code-ref ($rm_param) to which I want to
> send one argument ($self). Both calling forms seem to work. I'll be damned
> if I know some formal word OOD for it. :-)
I wouldn't have expected '$rm = &{$rm_param}($self);' to treat $rm_param as a
ref; I would think it would seek to treat $rm_param as the name of the sub;
But I checked the Camel book, and the two calls you describe are equivalent.
Originally, I thought you went with '$rm = $rm_param->($self);' out of
necessity, not just to prettify/obfuscate the call. Anywho, I think its
beautiful! <teardrop rolling down cheek> :)
This, of course, sent me back under the hood! :) It appears that the only way
to call a method by its name (as determined at runtime) is to wrap it in an
eval. At least that appears to be what you do here:
sub run {
...
# Process run mode!
my $body;
if (ref($rmeth) eq 'CODE') {
if ($autoload_mode) {
$body = $rmeth->($self, $rm);
} else {
$body = $rmeth->($self);
}
} else {
my $meth_call = '$self->' . $rmeth;
$meth_call .= '($rm)' if ($autoload_mode);
$body = eval($meth_call);
die ("Error executing run mode '$rm'. Eval of code '$meth_call' resulted in
error: " . $@) if ($@);
}
...
Bill
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]