demerphq <> writes:

> As you mention below statement modifiers have their place. For instance
>   next if $whatever;
> Is considered preferable to
> if ($whatever) {
>   next;
> }
> Similarly
> open my $fh, ">", $filename
>    or die "Failed to open '$filename': $!";
> Is considered preferable by most Perl programmers to:
> my $fh;
> if ( not open $fh, ">", $filename ) {
>   die "Failed to open '$filename': $!";
> }

Yeah, and that is for the same reason.  When you are trying to get a
birds-eye view of the codeflow, the former makes it clear that "we
do something, and then we open, and then we ...", without letting
the error handling (which also is rare case) distract us.

> "unless" often leads to maintenance errors as the expression gets more
> complicated over time,...

That might also be true, but my comment was not an endorsement for
(or suggestion against) use of unless.  I was commenting on
statement modifiers, which some people tend to overuse (or abuse)
and make the resulting code harder to follow.
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to