On 04/06/2016 03:20 PM, Jonathon Fernyhough wrote:
Hi,

I'm working my way through Learning Perl (6th) and Modern Perl (4th) and
was wondering whether there are any (non-obvious) drawbacks to the
different string quoting methods.

First up, double-quoted strings. The "usual method" of double-quoting
has an alternative of qq{For a string with $variable interpolation};


qq{} obviously wins when there would otherwise be a lot of escaping, but
are there any downsides of using this method more generally (other than
double-quotes being two characters shorter)? For example, is it "faster"
for Perl to parse a double-quoted string or does the compiler optimise
this out so the methods are fundamentally equivalent?
there is no semantic difference when using qq or q from their normal "" and ''. those are just syntactic sugar to lower the need for escaping.

Second, single- vs. double-quoted strings for non-interpolated use. In
Ruby, I've been given the impression* that single-quoted strings are
"more efficient" than double-quoted strings when interpolation is not
required (that is, prefer 'Bob' over "Bob"). I'm wondering whether there
is any similar recommendation for Perl?


my rule is for the reader and not the computer. i try to use '' when i know there is no interpolation and "" when there is. i am telling the reader to either not look or to look inside the string.

uri

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to