in reply to Re^8: Operator overloading with returning lists?
in thread Operator overloading with returning lists?

scalar affects the behaviour of the operator for which it sets the context. If perl was written in Perl, scalar would look something like

sub scalar { local $context = 'scalar'; return $child_op->(); }

scalar does not convert the result of the operator. If perl was written in Perl, scalar would NOT look like

sub scalar { return _coerce_to_scalar( $child_op->() ); }

In "scalar((1,2)x5)", scalar affects the behaviour of x.
In "scalar(@_)", scalar affects the behaviour of the array access.

Replies are listed 'Best First'.
Re^10: Operator overloading with returning lists?
by LanX (Saint) on Dec 01, 2008 at 17:04 UTC
    Thanx, good sumarization of the topic.

    just perldoc -f scalar

    There is no equivalent operator to force an expression to be interpolated in list context because in practice, this is never needed. If you really wanted to do so, however, you could use the construction @{[ (some expression) ]} , but usually a simple (some expression) suffices.
    "but usually a simple (some expression)" suffices looks like an unneccessary myth! ; )

    Cheers Rolf

      Indeed. Like it says earlier, "this is never needed".