Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

As others already stated, your code is confusing and yes, my rule would forbid that.

Your code has no more value than any of these (all clearer):

if (EXPR1) { return A }; if (EXPR2) { return B }; if (EXPR3) { return C }; die "unmatched case"; EXPR1 and return A; EXPR2 and return B; EXPR3 and return C; die "unmatched case"; return A if EXPR1; return B if EXPR2; return C if EXPR3; die "unmatched case";

For short expressions, my personal preference is the middle one. The first is the best choice if it is likely that the blocks can have statements before the return.

I personally do not like statement modifiers, so I would not choose the third option, but it is still by far better than your example.

Opinions differ though. TIMTOWTDI. But you still have shown no reason why my ruling would be rediculous. You only showed an example that strenghtens my opinion on it.


Enjoy, Have FUN! H.Merijn

In reply to Re^9: What's the right way to write a method which returns one line at a time from a file? by Tux
in thread What's the right way to write a method which returns one line at a time from a file? by Cody Fendant

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-03-29 05:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found