in reply to Re: Return Value of List-Producing Elements in Scalar Context
in thread Return Value of List-Producing Elements in Scalar Context
Maybe better phrased "a list-producing expression used in scalar context" will not produce an intermediate LIST which is then evaluated in scalar context, but a scalar is produced depending on the value.
DB<102> scalar (a..d) => "1E0" DB<103> sub tst {a..d} DB<104> tst() => ("a", "b", "c", "d") DB<105> scalar tst() => "1E0" DB<106> scalar ("a", "b", "c", "d") => "d" DB<107> sub tst { @{[a..d]} } DB<108> scalar tst() => 4
I wonder if a listify operator could help avoiding bugs when changing the return expression of a sub.
Cheers Rolf
( addicted to the Perl Programming Language)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Return Value of List-Producing Elements in Scalar Context
by AnomalousMonk (Archbishop) on Jul 28, 2013 at 15:21 UTC | |
by LanX (Saint) on Jul 28, 2013 at 18:09 UTC |