Perl Basics
Declare a scalar and print it.
On this page
The concept
A scalar variable starts with $. strict and warnings catch common mistakes. print writes the interpolated string.
Code example
Perl
use strict;
use warnings;
my $name = "Ada";
print "Hello, $name\n";Output
Hello, Ada
Follow the code
Open the walkthrough to inspect the example one step at a time.
Show guided walkthrough
Guided walkthroughReady
1
use strict;2
use warnings;3
my $name = "Ada";4
print "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
| Step / line | What happens | State after step | Output so far |
|---|---|---|---|
| Declare a scalar variable. | $name = "Ada" | — | |
| Interpolate name and print a newline. | $name = "Ada" | Hello, Ada |
Behind the scenes
How Perl processes this code
Perl compiles the script internally before executing it. strict and warnings help identify mistakes.