in reply to Re: if else in the other way
in thread if else in the other way
but a little bit more readable
Debatable :-)
For a simple yes/no print like this you are probably right. For lengthier outputs with, perhaps, a conditional part in the middle your way involves a lot of repeated text which can obscure meaning. Personally, in such cases I find this layout
print qq{Fixed part }, ( conditional expression ) ? qq{True part } : qq{False part }, qq{Further fixed text here\n};
more readable than this
( conditional expression ) ? print qq{Fixed part True part Further fixed text here\n} : print qq{Fixed part False part Further fixed text here\n};
particularly if the condition doesn't require parentheses, but others will probably disagree. I would be more likely to write the latter using an if ( ... ) { ... } else { ... } construct anyway as the meaning is more widely familiar.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: if else in the other way
by biohisham (Priest) on Oct 02, 2010 at 13:28 UTC |