All text strings that are not part of the Perl language, variable or function names must be quoted. Perl supports a variety of quoting conventions. The most important ones are placing text in single or double quotation marks.
Single quotation marks are strictest form of quotes. Everything between the quotes will be maintained 'as is'. If a string in single quotes is printed, for example, every character in the string will be printed literally.
Strings in double quotation marks are more flexible: they allow variable interpolation and escape sequences.
Any scalar variable, array, array or hash element that appears within double quotes will be replaced by its value when the string is printed or assigned to another variable.
$var = "world"; print "Hello, $var!"; output: Hello, world!
Many characters have special meanings in Perl. Among these are:
" ' # $ @ %
If these characters were included in a double-quoted string, the Perl interpreter would see them not as characters, but as the beginning of a quoted string, comment, or variable, respectively. Chances are that in such cases the program would crash.
Characters with special meanings can enclosed in double quotes as characters if they are preceded by a \
(backslash) character.
print "She said, \"Hello!\""; output: She said, "Hello!"
This rule also governs non-printing and whitespace characters, for example:
\n = newline \t = horizontal tab \a = alert (bell)
Perl comments are prefixed by the pound sign, #. Everything from the # character to the end of the line will be ignored.
# "a comment to be ignored by Perl interpreter" # Perl has no multi-line comments