http://www.perlmonks.org?node_id=730189


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

Replies are listed 'Best First'.
Re^4: OOP: ->Coderef for calling Private Methods (5.6?)
by tye (Sage) 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        

Re^4: OOP: ->Coderef for calling Private Methods
by LanX (Saint) 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