I tend to use
else (in these kinds of very simple cases) when the block before it occupies much in the way of vertical space in the editor window, but often exclude it when the preceding block is brief. That way the intent is obvious even when the introductory
if() clause is scrolled off of the top of the editor window. If I was doing that test, it'd be:
my $name = param('name');
if (defined $name && length $name) {
# I prefer to test for the pass case rather than the fail.
print "Thank you, $name, your submission is complete.\n";
} else {
print "Sorry, name can't be empty.\n";
}
exit;
Your two examples and mine are all functionally equivalent, so it's just a matter of how the author likes to see things done. No worries.
Edit for clarity: I also tend to minimize the use of exit and/or die whenever possible, which is why I included the else in my example. I use length in case the user's name is 0e0 or some such nonsense.