in reply to to paren or not to paren

G'day quixadhal,

When in doubt, you can check how Perl will parse your code fragment from the command line, rather than having to run a (test) script, with this:

perl -MO=Deparse,-p -e '... code fragment here ...'

See B::Deparse for more information about this.

"In most cases, I find I can happily write code which calls functions without needing to use those pesky parenthesis, other than to clarify which arguments are being passed, and which are part of another expression." [my emphasis]

Clarification is exactly what's needed here. Perl doesn't know if you meant

$self->selector->remove($self)->listener;

or

$self->selector->remove($self->listener);

Notice in the following what's valid and invalid syntax:

$ perl -MO=Deparse,-p -e '$self->selector->remove $self->listener;' Scalar found where operator expected at -e line 1, near "->remove $sel +f" (Missing operator before $self?) syntax error at -e line 1, near "->remove $self" -e had compilation errors.
$ perl -MO=Deparse,-p -e '$self->selector->remove($self)->listener;' $self->selector->remove($self)->listener; -e syntax OK
$ perl -MO=Deparse,-p -e '$self->selector->remove($self->listener);' $self->selector->remove($self->listener); -e syntax OK

For more information about calling methods, see perlobj. In particular, these three sections of that documentation:

-- Ken