++
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.
|