http://www.perlmonks.org?node_id=427695


in reply to Re^4: To Single Quote or to Double Quote: a benchmark
in thread To Single Quote or to Double Quote

If you read my post you'll see I added the "no $" after the original post. Ignoring those cases the single quote wins. You can blame the extra character if you want but i beleive that is the whole point here. If you use double quotes then you have to escape characters and it makes a noticable difference in speed. You should also have noticed that I mentioned the speed gain is minimal at very best. There is no reason at all to use these speed tests in a design choice.

for the rest because processing a backslash in a double quoted string means checking more cases than in a single quoted string. Isn't that realy the point that I was showing. Double quotes ARE slower because of the restrictions they impose, but they are only slower if it actualy contains something that needs escaped. Is that speed difference important? I would say not in normal use, but maybe for some special case.


___________
Eric Hodges
  • Comment on Re^5: To Single Quote or to Double Quote: a benchmark

Replies are listed 'Best First'.
Re^6: To Single Quote or to Double Quote: a benchmark
by Anonymous Monk on Feb 04, 2005 at 08:13 UTC
    Double quotes ARE slower because of the restrictions they impose, but they are only slower if it actualy contains something that needs escaped.
    Indeed, but let's go back to where it all started, shall we? Here's what the OP wrote:
    On occasions such as those when you don't care about the special properties of either single or double quotes, which is the best to use.
    Which to me means, the OP is talking about strings which don't have characters that are special - where the syntax of having single or double quotes doesn't matter. Obviously, if you have scalar or array sigils, or backslashes, the special properties of single or double quotes do matter - and are not the occasions we are talking about.