Perl: the Markov chain saw | |
PerlMonks |
Re: Class method names in a scalar variableby tobyink (Canon) |
on Dec 23, 2013 at 15:28 UTC ( [id://1068201]=note: print w/replies, xml ) | Need Help?? |
In addition to LanX's answer (which is correct), I'll point out that $self->$method->() is valid Perl; it just doesn't do what you want. $self->$method->() will call the method named in $method on the $self object; it then assumes that the method will return a coderef, and calls that coderef.
use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
In Section
Seekers of Perl Wisdom
|
|