I would do very much the same thing, with a little tweaking:
sub sg { my $res; # I won't assume COND being undefined is invalid if (COND) { $res = 1; } else { $res = 2; } die "Undefined result" unless defined $res; return $res; }
Of course, this I'd only use this if the code were much more complex than simply assigning the result.
In reply to Re^2: if else and not reachable coding style
by radiantmatrix
in thread if else and not reachable coding style
by szabgab
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |