Scalar and Text Basics
Numeric Context
Perl can use a scalar as text in one expression and as a number in another.
Numeric Context
numeric_context.pl
use strict;
use warnings;
my $raw = ;
my $doubled = $raw * 2;
my $text_code = $raw . "0";
print "raw=$raw\n";
print "doubled=$doubled\n";
print "text_code=$text_code\n";
use strict;
use warnings;
my $raw = ;
my $doubled = $raw * 2;
my $text_code = $raw . "0";
print "raw=$raw\n";
print "doubled=$doubled\n";
print "text_code=$text_code\n";
use strict;
use warnings;
my $raw = ;
my $doubled = $raw * 2;
my $text_code = $raw . "0";
print "raw=$raw\n";
print "doubled=$doubled\n";
print "text_code=$text_code\n";
context
Context is how Perl decides whether a value should be treated as text, a number, or a list.