in reply to Format / Logical Expression / Style Opinions: my, ternary, subroutine, @_
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Format Style Opinions: my, ternary, subroutine
by jffry (Hermit) on Dec 04, 2007 at 18:37 UTC | |
by webfiend (Vicar) on Dec 04, 2007 at 19:11 UTC |