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

Re^3: OOP: ->Coderef for calling Private Methods

by ccn (Vicar)
on Dec 13, 2008 at 19:48 UTC ( #730189=note: print w/ replies, xml ) Need Help??


in reply to Re^2: OOP: ->Coderef for calling Private Methods
in thread OOP: Obj->Coderef for calling Private Methods

Perl 5.6 does not have that feature (perlop 5.6). That explains why hackers use underscores and merlyn did not mention it in his book.

Perl doesn't care about $code_ref having to be a reference to a method. It's enough to be just a sub ref. The sub gets an $obj as first argument, that's all.

Update: broken link fixed


Comment on Re^3: OOP: ->Coderef for calling Private Methods
Select or Download Code
Re^4: OOP: ->Coderef for calling Private Methods
by LanX (Canon) on Dec 13, 2008 at 19:50 UTC
    Thank you that's helpful! 8 )

    Do you agree that it could be more documented?

    Cheers Rolf

Re^4: OOP: ->Coderef for calling Private Methods (5.6?)
by tye (Cardinal) on Dec 13, 2008 at 20:19 UTC
    Perl 5.6 does not have that feature

    Testing 5.005_03 shows that even it had the feature of $obj->$code_ref( ... ), despite the 5.6 documentation not mentioning it:

    $ perl5.00503 -e '$cr= sub { warn "( @_ )\n" }; "main"->$cr( "bar" )' ( main bar )

    - tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://730189]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2014-09-15 05:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (145 votes), past polls