quoting philosophy

L

Larry

Perl gurus... What's your "philosophy" about single vs. double quotes,
where you're not using any interpolation.

i.e.

$x = 'foo';

or

$x = "foo";

I know there are weightier issues to spend time worrying about
but... :)
 
M

Michele Dondi

Perl gurus... What's your "philosophy" about single vs. double quotes,
where you're not using any interpolation.

When I don't use interpolation or escapes, then I prefer single
quotes. But it still all depend on the context. In some specific
situations I use alternate delimiters both when I need interpolation
and when I don't.


Michele
 
D

Dr.Ruud

Larry schreef:
Perl gurus... What's your "philosophy" about single vs. double quotes,
where you're not using any interpolation. i.e.
$x = 'foo';
or
$x = "foo";

The compiler will quickly decide that no interpolation is possible for
"foo", so will treat it the same as 'foo'. So towards the compiler there
is no difference, until you write something like "(e-mail address removed)" or
qq{[email protected]} or

$test = <<EOT;
(e-mail address removed)
EOT

In practice, the '' format is a contract that no interpolation/expansion
is meant nor will happen, and the "" format means that you have to read
much more carefully.
 
X

xhoster

Larry said:
Perl gurus... What's your "philosophy" about single vs. double quotes,
where you're not using any interpolation.

i.e.

$x = 'foo';

or

$x = "foo";

If you have a string literal which is simple, what is more likely: that it
will need to be changed to include an interpolation or newline or tab at
some point in the future; or that it will need to be changed to include
a literal @ or $ or \ in the future? I find that the former is far
more common than the latter, so now I tend to use double quotes rather
than single quotes for simple string literals. The main exception is
small literal hash keys (but now I tend not to quote them at all).

Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,205
Messages
2,571,067
Members
47,673
Latest member
MahaliaPal

Latest Threads

Top