No, this is a compile time thing and buys you nearly nothing performance-wise.

The relatively recent arguments for using single-quotes on strings which have no interpolation is motivated by an intent to inform a reader whether a string literal is interpolated or not.

In my coding, I made an extended trial of using single-quotes on all uninterpolated strings. I found the practice unproductive both as a maintainer and as an author. As a maintainer, most of my strings are not so long as to be problematic. As an author, I found double-quotes to be more flexible--too often the final interpolative nature of the string was unknown when the quotes were opened.

It might seem that there would be more benefit to this practice when using very long strings. I did not find this to be the case; with long string literals it is work to determine if you are looking a one literal or a list or concatenation of literals.

I'm sure experience and personal taste vary, but I find literals which are more than a line to be most easily readable in this form:

my $usage = "This is just a literal string concat'd up; " . "it keeps significant\n" . "whitespace and interpolations in normal or " . $visible . "places. Double-quotes seem most convenient " . "just to contain simple things like newlines " . "and tabs.\n" . "But the important thing is that the dots " . "make it easy to see that each line starts\n" . "a new token\n";
I use and like syntax highlighting, but haven't made it a prerequisite to reading code as it is not always conveniently available. I find highlighting helpful when writing to catch unterminated literals, but I tend to ignore highlighting when just reading code.

For what it is worth, my experiment was motivated by the thought that my use of double-quotes was just a habit carried over from C.

Be well,
rir


In reply to Re: Optimizing Perl Code - single versus double quotes really that important? by rir
in thread Optimizing Perl Code - single versus double quotes really that important? by MashMashy

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.