Uri Guttman wrote:
>>>>>> "r" == rkb <[email protected]> writes:
[snip]
> r> I often use the ternary operator when working with
> r> dispatch tables. Based on your comment, I suspect
> that
> r> you feel that the following example is a poor use of
> the
> r> ternary operator. Please correct me if I'm wrong.
>
> r> exists $dispatch{$status} ? $dispatch{$status}->()
> r> : $dispatch{'error'}->();
>
> you don't need exists on a dispatch table. and i code them
> like this:
>
> my $code = $dispatch{$status} || $dispatch{'error'} ;
> $code->() ;
>
> very clean, no duplication of $dispatch{$status} or the
> code call, easy
> to see the error case.
>
> uri
Yes, that does look like a better approach.
Thanks
Ron Bergin
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/