Single-Quoted String Literals.
A single-quoted string literal is a sequence of characters enclosed in single quotes. The single quotes are not part of the string iteself.
‘hello\n’ # hello followed by backslash followed by n
Double-Quoted String Literals
It’s a sequence of characters, although this time enclosed in double quotes. But now the backslash takes on its full power to specify certain control characters.
“hello\n” # hello, and a newline
If you wish to use backslash escape(like \n to mean a newline character), you will need to use the double quotes.
- from Leaning Perl 5E
Sample code
#!C:\Perl\bin\perl.exe use strict; use warnings; print '\'\\'; print "\n"; print 'Hello World!\n'; print "\n"; print "Hello World!\n";
Output
'\ Hello World!\n Hello World!