[tpm] Is there a three-way version of...

Madison Kelly linux at alteeve.com
Fri May 29 13:17:14 PDT 2009


Mike Stok wrote:
> 
> On May 29, 2009, at 4:01 PM, G. Matthew Rice wrote:
> 
>> Madison Kelly <linux at alteeve.com> writes:
>>>> a table-like way is adviced.
>>>> my $title = $condition1 ? 'result1'
>>>>              : $condition2 ? 'result2'
>>>>              : $condition 3 ? 'result3'
>>>>             # ... more lines here
>>
>> Yuch.  Looks like C :)
>>
>> Mine looks similar to another one I saw:
>>
>>    my $title = {aa => 'bing', bb => 'bang'}->{$key} || 'bong';
> 
> 
> Or even use // there if your perl is recent enough, in case you ever 
> might have cases involving false but defined strings.
> 
>   my $title = { aa => 'bing', bb => 'bang', cc => '0', dd => '' 
> }->{$key} // 'bong';
> 
> Mike
> 

I'm not familiar with the '//' operator. It is ... ?

Madi


More information about the toronto-pm mailing list