in reply to Perl ternary operator style

I agree with BrowserUK and others about appropriate use of || or //.

More generally, I would say ternary operator is great when you have simple values to compare. If the terms become complicated, you want something else, maybe an actual IF block. It's not just a matter of making the code work correctly. The code needs to be decipherable for the sucker who has to read it six months from now to implement some change requirement.

As Occam said: Entia non sunt multiplicanda praeter necessitatem.

Replies are listed 'Best First'.
Re^2: Perl ternary operator style
by David Clarke (Initiate) on Jun 01, 2011 at 14:03 UTC
    Many thanks, TomDLux (and others) for pointing out that my use of ?: in this kind of situation is blindingly (to the subsequence reader) over-complex. I think this is a case where copy-paste-reuse has become embedded in some of my work, and ternary is the norm. I'll go an re-evaluate what is actually needed. David Clarke.