Linguistically, "if then else, otherwise" doesn't make sense, since 'else'
and 'otherwise' are synonymous.
? : : suffers from the same problem, just in terms of the ternary ?:
operator (which of course, wouldn't be ternary anymore) instead of English.
I'm not sure if there will be ambiguity where the standalone colon is being
used elsewhere, but I suspect that it would make parsing more difficult.
(At least in a BNF grammar.)
Regardless of how you perceive the results of <=> and cmp, it's still two
conditionals. Something has to make the differentiation between positive
and negative.
You're simply asking for another way of writing 'if {} elsif {} else {}',
because you don't like 'elsif'. Fine. As has been said before, use a
switch.
given ($cond) {
when 1:
when 0:
when -1:
}
Is the marker still ^_?
given ($cond) {
when ^_ > 0:
when ^_ < 0:
default: # Or whatever default will be named.
}
Still too verbose? Let's look at your example....
> $whereCond = $cond ? ' field > $x AND ' : '' : ' field < $x AND';
> $Query = qq{ SELECT .... FROM ... WHERE $whereCond ...};
I think if you specify WHERE you need a clause.
'SELECT foo FROM bar WHERE' doesn't make sense.
my @c = qw( = > < );
$x = 60;
foreach my $cond (40 <=> $x,60 <=> $x,80 <=> $x) {
$query = qq{ SELECT ... FROM ... WHERE field $c[$cond] $x };
print "$query\n";
}
Even less to type. Maybe not all *that* clear, but no less than ?:, ?::,
and ?:?: all meaning different things.
--
Bryan C. Warnock
[EMAIL PROTECTED]