in reply to Optimizing Perl Code - single versus double quotes really that important?

ikegami pointed out already that perl will compile your string literals the same whether they use double quotes or single quotes. Why I'm strict about using single quotes and double quotes differently in my code isn't about the code's performance.

It's about my performance. If I see double quotes and no variable, I wonder what I was planning to interpolate that isn't in the code now. If I see single quotes and a variable, I wonder for a moment why I didn't use double quotes or qq(). Parsing within the constructs is different, and I try to use the one that gives me the desired behavior. In cases in which there's no difference in final behavior, I tend to opt for single quotes just out of consistency. In my code as a rule, interpolating constructs are only used to interpolate something. The types of bugs that helps me avoid are small and simple to fix, but I've found they are quite common if I don't use the rule.

  • Comment on Re: Optimizing Perl Code - single versus double quotes really that important?
  • Download Code

Replies are listed 'Best First'.
Re^2: Optimizing Perl Code - single versus double quotes really that important?
by ruzam (Curate) on Feb 05, 2009 at 18:56 UTC
    Same here. Plus, my code editor highlights '' strings an "" strings with different colours so it helps with spotting where variable substitutions might be buried.