Perl Basics

Declare a scalar and print it.

Perl
use strict;
use warnings;
my $name = "Ada";
print "Hello, $name\n";
Output
Hello, Ada

Explanation

A scalar variable starts with $. strict and warnings catch common mistakes. print writes the interpolated string.

Explore the dry run
Guided walkthroughReady
1use strict;
2use warnings;
3my $name = "Ada";
4print "Hello, $name\n";

Follow the example

Start to inspect the source, values, and output. These prepared steps explain the published sample; grouped loop steps describe multiple iterations.

View the complete dry-run table
Prepared trace of the published program. Some rows group repeated iterations.
Step / lineWhat happensState after stepOutput so far
Declare a scalar variable.$name = "Ada"
—
Interpolate name and print a newline.$name = "Ada"
Hello, Ada