Hello, World

The smallest Perl program, use v5.40, and printing with say and print.

Runs in Zerethon IDE · Perl 5.40 Official Perl documentation ↗

A Perl file runs from top to bottom. Start every program with use v5.40;: it turns on strict (variables must be declared), warnings, say, subroutine signatures and try / catch.

main.pl
use v5.40;

say "Hello, World!";
say "Sum: ", 2 + 3;
print "a-b!\n";
my $name = "Ada";
say "Hi, $name";

Output

Hello, World!
Sum: 5
a-b!
Hi, Ada
  • say adds a newline; print does not.
  • Variables inside double quotes are replaced by their value; single quotes keep the text exactly as written.
  • Statements end with ;. A line starting with # is a comment.