Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: if/else syntax

by massa (Hermit)
on Jun 29, 2009 at 13:53 UTC ( [id://775676]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://775676]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-19 19:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found