I do not want to argue endlessly, especially in view of the fact that we probably mostly agree and that the whole discussion really stems from a quick comment I made on the possible motivation of the OP, nothing fundamental. I just want to set the record straight on a couple of things.

The Camel Book edition I mentioned was issued in 2012 and the revision probably occurred in 2011. The cover says prominently "Covers version 5.14". So, pretty recent stuff. The relevant section is about programming style, not efficiency or performance.

"The inefficiency of map in a void context" may be cargo cult, but I did not say anything like that or even remotely similar to that, not even hinted anything in that direction. I vaguely remember having read things about that about 10 years ago, but it is absolutely not my belief, I simply have no opinion on that because I do not know. I ran a test a few weeks ago comparing map and foreach, and, in the specific context of my specific test (quite different from the case in point), foreach turned out to be slightly faster (25%). This is the only reason why I said "possibly faster". I was not repeating some sacred mantras read somewhere, and there is really nothing in what I said that could lead anyone to believe that this is what I was doing.

I have some interest in the functional programming paradigm, because I think it created or promoted a lot of very interesting and powerful concepts (list processing, higher order functions, closures, lazy evaluation, etc.), but I never used any functional language anywhere beyond making some toy programs to get a feeling of it. My background before Perl was Fortran, Modula, ADA, assembly, C, C++, TCL, Python, awk, shell, PL-SQL and quite a few other languages, none of them functional. But I love the fact that Perl offers me the possibility to use some of the useful concepts it has borrowed from functional programming, because it gives me extra expressive power. But, of course, I have many other reasons to love Perl, some of which are certainly much more significant.


In reply to Re^6: Write code diferently by Laurent_R
in thread Write code diferently by madM

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.