On Thu, 7 Jun 2001, M.W. Koskamp wrote:

> > They're bad mainly because they suggest that the author doesn't understand
> > Perl well.  So if I see code like that, my spidey sense starts tingling
> and
> > I wonder how good the code is.  Why would someone type unnecessary quotes
> > unless they were confusing Perl with the Bourne shell, in which case they
> > may well have made some real mistakes?
>
> I dont agree with that.
> Using quotes in print statements is a good habit. It makes code more
> readble, since it is clear that the intention is to print a scalar value as
> a string.
> Without quotes the scalar value could also be a FileHandle instance or a
> subroutine reference.
> So i think proper quoting is not making your code bad.

It's a contextual thing -- it's appropriate for some things and not
appropriate for other things.  In this case:

  print "$x";

the quotes are unnecessary.  If $x happens to be a reference, then you
are going to not get the correct output.  Double quoted strings are only
necessary when you need variable interpolation within a string.  Since in
the above case $x is the only thing being printed, variable interpolation
isn't needed.

-- Brett

Brett W. McCoy
Software Engineer
Broadsoft, Inc.
240-364-5225
[EMAIL PROTECTED]

Reply via email to