in reply to Re: if else and not reachable coding style
in thread if else and not reachable coding style
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.
|
|---|