++ My response may come across as negative. That's not my intention so I'm just letting you know that I upvoted your post before replying. :-)

"I hadn't thought of the speed implications."

Unless you're experiencing noticeable speed issues, continue to not think about it. This sort of micro-optimisation is rarely useful: you'll spend inordinate amounts of time possibly saving just some nanoseconds when it would be more productive to focus on the code in general.

"But I guess concatenation is always going to be faster than interpolation."

Don't guess; instead, Benchmark.

I seem to recall 20+ years ago, when coding to v5.6, various forms of concatenation (e.g. join '', $x, $y or $x . $y or "$x$y" or others) provided certain performance benefits. Reading the optimisation sections of release notes over the years has shown that these benefits have largely dissipated.

In the main, I would focus on readability. For instance, many authors eschew whitespace, resulting in code like $x.'.'.$y which I find difficult to read at first glance, and often require me to do a doubletake to determine what each dot is doing.

This advice pertains to many aspects of Perl syntax, not just concatenation, which perhaps had some benefits in the past but have been optimised away as the language has matured.

— Ken


In reply to Re^4: What to test in a new module by kcott
in thread What to test in a new module by Bod

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.