We all have to have uses for our overly powerful pentium toaster units, don't we ? :)

No, seriously, thanks for the feedback, though I would hope the case 1 and case2 would have been equivalent, essentially map is going to create an array, and we are saying that assignment for an array is slower than a push, or are we instead saying that the blocks { } are the slowdown? Either way, it seems we can get more granularity from this test to learn more about the internals.

Anyhow, this all really matters when dealing with the size of input, usually memory is cheap and in surplus, so you just want speed ... yet not always...

As a last note, the bestest fastest is not always the best way, given that readability and maintainability is important. Hence you might have to add blocks later, or maybe blocks add clarity, and definitely the push appears hackish -- if not indicative of a bug somewhere. I wouldn't leave production code using that final push.


In reply to Re: Re: using map and anonymous subroutines by flyingmoose
in thread using map and anonymous subroutines by ritontor

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.