On Wed, 08 Oct 2008 04:59:19 -0700, John W. Krahn wrote:
> oldyork90 wrote:
>> I am using a module having documentation saying document() is a
>> method. However, I see it used as
>>
>> $o->document;
>>
>> Can you reference a method in this way? (I takes no args). I always
>> thought
>>
>> $o->document() and $o->document meant different things, function
>> verses attribute.
>
> perldoc perlsub
>
> To call subroutines:
>
> NAME(LIST); # & is optional with parentheses.
> NAME LIST; # Parentheses optional if predeclared/imported.
> &NAME(LIST); # Circumvent prototypes.
> &NAME; # Makes current @_ visible to called subroutine.
That isn't particularly relevant to the effect of leaving parentheses off
method calls. You don't use & with methods (unless you're being
perverse). Methods ignore prototypes. And @_ is not passed through when
parens are left out on method calls.
In fact, I can't find anything in perldoc about parens being optional on
method calls. All the examples I find leave in even empty ones. Of
course you can leave them out. Parenthesis-less calls are documented in
the Camel ("Method Invocation") but not given any special attention.
I guess that got added in the third edition when there started to be
divergence between the Camel and perldoc.
--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/