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
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 |