Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Class method names in a scalar variable

by tobyink (Abbot)
on Dec 23, 2013 at 15:28 UTC ( #1068201=note: print w/replies, xml ) Need Help??


in reply to Class method names in a scalar variable

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1068201]
help
Chatterbox?
[choroba]: Good morning!
[shmem]: GDPR meets butcher's shop
[marto]: if only Spectre had remained a fictional organisation :P https://www. phoronix.com/scan. php?page=news_item &px=Spectre-V3-V4- Vulnerabilities
[marto]: 'GDPR meats butcher's shop'?

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2018-05-22 07:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?