Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
At first glance, this node appeared to revolve around avoiding problems that mainly exist for a developer if the familar, self-documenting and more maintainable construct "if {} else {}" is discarded and replaced by "?:". It doesn't seem to be about operator precedence in general.

I'm not overjoyed by the examples, either.

What?? How about
my $y = 1; $y = 0 if (!$x);
or, if you actually need a regular expression:
my $y = "a big string of something"; if (!$x) { $y =~ s/somebigoldregex/etc/; }
The above are more readable and make it fairly obvious what is going on. These attributes are very important. If someone (might even be you) has to debug a problem involving your code at 1 am on 5 cups of bad coffee, they're going to understand it faster and will be less likely to want to murder you when they're done. Even better, by writing clearer code you reduce the chances that you or somebody else will need to debug your code in the wee hours in the first place.

This may seem like a harsh response, but I gave you a ++ for your effort and enthusiasm. I would however like to propose that this node comes out of Tutorials, but only until it is reworked into a straightforward "how to use ?:" tutorial which does not even remotely look like it is encouraging the replacement of if/else statements in general. There are (a few) places where the ternary is useful and good, and it's fine to help people write them correctly. Coming up with more realistic examples would be nice. In addition, the title should be changed to something more meaningful.

In reply to Re: Precedence for Idiots by virtualsue
in thread Precedence for Idiots by Melly

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?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2022-12-05 10:45 GMT
Find Nodes?
    Voting Booth?

    No recent polls found