in reply to Coding styles using if/else
Personally, I think it could be somehow a pathological case such as an implicit return from a sub, assuming you're just trying to avoid having following code executed; the exit; statement is fine though, if you explicitly want to exit. In former case, it works well, as long as you don't change anything - but, all of a sudden, it may break if you do (possibly triggered by removing/commenting the exit; statement accidentally).
As a side note:
If you're worried about the total size of the if {} else {} clause, you could give the ternary conditional operator (?:) a try (assuming your code doesn't continue below the ternary operator statement in this peculiar case):
($name eq "") ? print q{Sorry, name can't be empty} : print "Thank you, $name. Your submission is complete.";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Coding styles using if/else
by blazar (Canon) on Apr 24, 2007 at 11:27 UTC |