in reply to Re^2: wantarray alternative
in thread wantarray alternative
just return the list! In scalar context the last element is taken, so if you are only returning "one value in the return list" thats the same.
It's the scalar of an array(!) which counts.
ok not that easy, avoid scalar context and explicitly put the scalar into a list at LHS.
DB<129> @out=A..C => ("A", "B", "C") DB<130> sub tst { return map{lc} @out } DB<131> @list = tst() => ("a", "b", "c") DB<132> ($scalar) = tst() => "a"
Though we asked several times you haven't clarified which result you expect in in case of scalar context and longer list!
Cheers Rolf
( addicted to the Perl Programming Language)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: wantarray alternative
by tqisjim (Beadle) on Jul 10, 2013 at 20:22 UTC | |
by LanX (Saint) on Jul 10, 2013 at 20:24 UTC | |
by tqisjim (Beadle) on Jul 10, 2013 at 21:04 UTC | |
by LanX (Saint) on Jul 10, 2013 at 21:10 UTC |