Perl Language Strings and quoting methods String Literal Quoting


Example

String literals imply no escaping or interpolation ( with the exception of quoting string terminators )

print 'This is a string literal\n'; # emits a literal \ and n to terminal

print 'This literal contains a \'postraphe '; # emits the ' but not its preceding \

You can use alternative quoting mechanisms to avoid clashes:

print q/This is is a literal \' <-- 2 characters /;  # prints both \ and '
print q^This is is a literal \' <-- 2 characters ^;  # also

Certain chosen quote characters are "balanced"

print q{ This is a literal and I contain { parens! } }; # prints inner { }