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