|Problems? Is your data what you think it is?|
Re: Optimizing Perl Code - single versus double quotes really that important?by rir (Vicar)
|on Feb 05, 2009 at 18:38 UTC||Need Help??|
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:
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.