in reply to if/else syntax

Perl has a nice thing that allows "reversing" the if and a SINGLE action statement.
single_action_statement...if(blah)...

This is not what you have here!
And I would argue that your code C code is bad because it is not clear.

better:

if ( $someVar == $anotherVar ) { someFunc(); } else { anotherFunc(); }
You are making a HUGE mistake if you think that number of source code lines equals efficiency - I would recommend some advanced C classes or ASM classes. The compiler whether it be "Perl" or "C" can deal with the above construct VERY efficiently.

Replies are listed 'Best First'.
Re^2: if/else syntax
by massa (Hermit) on Jun 29, 2009 at 13:53 UTC
    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 (κς,πμ,πλ)
      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.