Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??
Then please, implement a benchmark that exhibits the savings you are concerned about. My benchmark was simply to show that it was not a given that 'each' is faster (or better). The reason they are building arrays is to validate each function does the same thing; given they are both doing the same thing in that regard, the only difference is in the raw speed of an 'each' (and push) loop vs. getting a list of values from keys and values.

Indeed, the semantics of 'each' are clearly defined and obvious. The results of those semantics in a large body of code is not. It's essentially an action-at-a-distance effect. Understanding how that became a problem (in the event it does), and how to find what did it, can make for a very difficult bug to track down.

This is essentially the same reason global variables are generally avoided. If you can always avoid the problems with 'each', and do so when others are looking at and maintaining your code, please, let us all know how you accomplish it; it would go a long way to redeeming 'each' in my opinion, at least.

In reply to Re^6: keys and values order on a hash by Somni
in thread keys and values order on a hash by citromatik

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.