I no longer fear the ternary operator, so this is readable enough. There must be a clearer way to express the logic, though. Having the first parameter be undefined when @_ isn't quite long enough, and croaking if @_ isn't exactly the right length ... it makes my brain hurt a little.
What about switching around the order of the parameters?
sub xyz { my ($xxx, $yyy, $ttt) = @_; # You could also say -> if( !$xxx || !$yyy ) # if you wanted to avoid 'unless' like the PBB says unless ($xxx && $yyy) { croak('Not good.'); } # ... }
This way we don't have to enforce a specific size for @_, too. Double bonus.
In reply to Re: Format Style Opinions: my, ternary, subroutine
by webfiend
in thread Format / Logical Expression / Style Opinions: my, ternary, subroutine, @_
by jffry
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |