DEVFYI - Developer Resource - FYI

Perl uses single or double quotes to surround a zero or more characters. Are the single(' ') or double quotes (" ") identical?

Perl Questions and Answers


(Continued from previous question...)

Perl uses single or double quotes to surround a zero or more characters. Are the single(' ') or double quotes (" ") identical?

They are not identical. There are several differences between using single quotes and double quotes for strings.
1. The double-quoted string will perform variable interpolation on its contents. That is, any variable references inside the quotes will be replaced by the actual values.
2. The single-quoted string will print just like it is. It doesn't care the dollar signs.
3. The double-quoted string can contain the escape characters like newline, tab, carraige return, etc.
4. The single-quoted string can contain the escape sequences, like single quote, backward slash, etc.

(Continued on next question...)

Other Interview Questions