I find it almost completely unreadable, and disagree vehemently with PBP's suggestion that nested ternaries are anything other than a horrible idea.
I can think of no good reason why this simple functionality should be written so tersely, when a more sensible approach takes up almost the same amount of space.
sub xyz { my ( $ttt, $xxx, $yyy ); ( $xxx, $yyy ) = @_ if @_ == 2; ( $ttt, $xxx, $yyy ) = @_ if @_ == 3; croak 'Not good' unless $xxx and $yyy; }
As a tangent, I'd also consider thinking about why you have a sub where the first parameter is optional -- it's a lot easier if optional parameters go on the end.
In reply to Re: Format Style Opinions: my, ternary, subroutine
by friedo
in thread Format / Logical Expression / Style Opinions: my, ternary, subroutine, @_
by jffry
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |