Tutorial by Examples

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...
Double-quoted strings use interpolation and escaping – unlike single-quoted strings. To double-quote a string, use either double quotes " or the qq operator. my $greeting = "Hello!\n"; print $greeting; # => Hello! (followed by a linefeed) my $bush = "They misunderestimat...
Large Multi-Line strings are burdensome to write. my $variable = <<'EOF'; this block of text is interpreted literally, no \'quotes matter, they're just text only the trailing left-aligned EOF matters. EOF NB: Make sure you ignore stack-overflows syntax highlighter: It is very wrong. A...
The function chomp will remove one newline character, if present, from each scalar passed to it. chomp will mutate the original string and will return the number of characters removed my $str = "Hello World\n\n"; my $removed = chomp($str); print $str; # "Hello World\n" pr...

Page 1 of 1