From: ian.goodacre@xtra.co.nz (via RT) Date: Fri, 2 Jan 2009 13:36:54 +0000 (+0100) Subject: [perl #61392] Method call documentation in perlobj.pod X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e947c198f4d08c5b6342363b752901f195bc5cb5;p=p5sagit%2Fp5-mst-13.2.git [perl #61392] Method call documentation in perlobj.pod --- diff --git a/pod/perlobj.pod b/pod/perlobj.pod index b0592ff..5b6adba 100644 --- a/pod/perlobj.pod +++ b/pod/perlobj.pod @@ -313,6 +313,19 @@ The right side of the arrow typically is the method name, but a simple scalar variable containing either the method name or a subroutine reference can also be used. +If the right side of the arrow is a scalar containing a reference +to a subroutine, then this is equivalent to calling the referenced +subroutine directly with the class name or object on the left side +of the arrow as its first argument. No lookup is done and there is +no requirement that the subroutine be defined in any package related +to the class name or object on the left side of the arrow. + +For example, the following calls to $display are equivalent: + + my $display = sub { my $self = shift; ... }; + $fred->$display("Height", "Weight"); + $display->($fred, "Height", "Weight"); + =head2 Indirect Object Syntax X X X