Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^5: Useless use of string in return statement

by jdporter (Paladin)
on Apr 13, 2021 at 16:15 UTC ( [id://11131202]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11131202]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-19 05:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found