in reply to Re^4: Useless use of string in return statement
in thread Useless use of string in return statement

Someone, I believe it was Larry, said that the choice should be made such that the "most important part" of the statement comes first/leftmost. So in the case of error handling - such as the failure of open - using the modifier 'if' is appropriate.

  • Comment on Re^5: Useless use of string in return statement

Replies are listed 'Best First'.
Re^6: Useless use of string in return statement
by Tux (Canon) on Apr 13, 2021 at 16:20 UTC

    But what *is* the most important part with errors?

    die "I hate you" if $string =~ m/error/i;

    or

    $string =~ m/error/i and die "I hate you";

    As with most, it is a matter of taste and brain. *My* brain 100% prefers the second over the first. Note that I am not of native English tongue. That might matter.

    My rule of thumb is to forbid all postfix if/unless except when the expression is a simple $debug / $verbose >= $n.


    Enjoy, Have FUN! H.Merijn

      I agree... and now I realize that I mis-wrote when I said "modifier if". I actually meant 'and', as you showed.