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.

<-radiant.matrix->
A collection of thoughts and links from the minds of geeks
The Code that can be seen is not the true Code
I haven't found a problem yet that can't be solved by a well-placed trebuchet