develooper Front page | perl.perl6.language.data | Postings from September 2000

Re: RFC 328 (v1) Single quotes don't interpolate \' and \\

Thread Next
From:
Hildo Biersma
Date:
September 29, 2000 01:59
Subject:
Re: RFC 328 (v1) Single quotes don't interpolate \' and \\
Message ID:
39D459C5.67E59A40@msdw.com
 
> =head1 ABSTRACT
> 
> Remove all interpolation within single quotes and the C<q()> operator, to
> make single quotes 100% shell-like. C<\> rather than C<\\> gives a single
> backslash; use double quotes or C<q()> if you need a single quote in your
> string.

Single-quoted strings need to be able to contain single quotes, which
means some escape mechanism is required.

So,
  $line = 'This string contains both single \' and double " quotes';
needs an escape.  It would be silly to have an escape character
different from the backslash that everything else uses.

We also need to be able to do:
  $line = 'This single-quoted string ends on a backslash \';
Oops.  Which is why that is spelled:
  $line = 'This single-quoted string ends on a backslash \\';
Again, the same escape mechanism is used.

Conceivably, we could say that \\ in the middle of a single-quoted
string is not escaped, i.e. it means two backslashes, that that way lies
madness.

So, I'd say, leave single quotes as they are.  The two escapes are
useful and required, as I've demonstrated above.

Hildo

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About