in reply to Re: if/else syntax
in thread if/else syntax

One can start a holy war (specially in a Perl forum) about more characters/lines versus readability/maintainability. I, for instance, am of the school of thought that goes "as long it does not _obscure_ the meaning, the shorter the better". That way, I prefer
$someVar == $anotherVar ? someFunc() : anotherFunc()
over _any_ of the alternatives because it's elegant, concise and _absolutely_ clear. ikegami pointed out to me that ?: can get really messy really fast. I agree. But in the case at hand, it's unbeatable IMHO.
[]s, HTH, Massa (κς,πμ,πλ)

Replies are listed 'Best First'.
Re^3: if/else syntax
by Marshall (Canon) on Jun 29, 2009 at 14:26 UTC
    I don't want to start a holy war either! Your formulation is completely acceptable to me. For a short thing like this, I use it all the time. The OP said that he/she didn't like this syntax. If so, then use if{}else{} (my opinion). I don't see a problem here. As a matter of style, I would put parens around the conditional, but that is a very minor point.