On Sunday 29 July 2001 04:32 pm, raptor wrote:
> index(ref $var, 'A') - 1 ? SCALAR-LVALUE-case : HASH-case : ARRAY-case;

That one is actually rather clever....

Most of your examples, however, look like you are attempting to bandage some 
poorly designed code upstream.  (Perhaps not, but writing logic built around 
<=> or cmp as a control flow is rarely a good idea.)  

>
> $x = $a <=> $b ? $a : $default : $b;
>

This was your lone example that actually made some sense, and the only 
non-standard answers (by which I mean conventional control flow methods) I 
can think of are:

$x = ($default,$a,$b)[$b<=>$a];  # Much like I did before

($x) = sort { $a <=> $b or $default } ($a,$b);
# Since <=> and cmp were created more-or-less specifically for sort

The former is faster than the latter, but neither are as quick as the more 
conventional structures.

-- 
Bryan C. Warnock
[EMAIL PROTECTED]

Reply via email to