On Wed, Apr 29, 2009 at 4:24 PM, Graham Barr <gbarr@pobox.com> wrote:
>
> The value of a block has always been the value of the last statement
> executed.
> This is how subs get a default return value unless you explicitly do
> return;
Right. So it's reasonable to expect C< do { given ... } > to do what Hakim
expected.
By the way, you can fake up a ternary l-value by explicitly dereferencing
the result of the expression:
${ $result_goes_there ? \$there : \$here } = get_result();
I want ternary l-values! C< ( $result_goes_there ? $there : $here ) =
get_result() > should work IMO, especially in a language that allows one to
do
sub ifl : lvalue { $_[0] ? $_[1] : $_[2] }
ifl($result_goes_there, $there, $here) = get_result();
... testing ...
Oh. We /DO/ have ternary allowed as an l-value:
$ perl -wle '( $result_goes_there ? $there : $here ) = get_result(); sub
get_result { 27} print "h:$here";print "t:$the
re"'
indicates that $here was set to 27 and $there was undefined.
Thread Previous
|
Thread Next