Indented heredocs in Perl
Multi-line strings with <<~, which strips the indentation so the code stays pretty.
use strict;
use warnings;
my $name = "Ada";
my $greeting = <<~"END";
Hello, $name!
Welcome aboard.
END
print $greeting;
# single quotes: no interpolation
my $raw = <<~'END';
Sigils like $name stay literal here.
END
print $raw;
How it works
<<~"END"starts a heredoc that interpolates$nameand drops the leading spaces from every line.- The body runs until a line holding only the terminator, which may be indented too.
- With single quotes,
<<~'END'takes the text literally — sigils like$namestay as typed.
Keywords and builtins used here
ENDmyprintuse
The run, in numbers
- Lines
- 15
- Characters to type
- 228
- Tokens
- 55
- Three-star pace
- 75 tpm
At the three-star pace of 75 tokens a minute, this run takes about 44 seconds.
Step 3 of 3 in Strings, step 15 of 27 in Language basics.