On Thu, Apr 30, 2009 at 01:01:10AM -0700, Michael G Schwern wrote:
> David Nicol wrote:
> > 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:$there"'
> > indicates that $here was set to 27 and $there was undefined.
>
> Oh god, that's AWESOME! I'm going to find an excuse to use that in production
> tomorrow.
It's even documented in perlop. Rather unfortunately (IMHO), the
following wonderful line has been removed from that document:
This is not necessarily guaranteed to contribute to the readability of
your program.
--
Paul Johnson - paul@pjcj.net
http://www.pjcj.net
Thread Previous
|
Thread Next