Um escalar é uma variável que armazena uma única unidade de dados por vez. Os dados que serão armazenados pela variável escalar podem ser de tipos diferentes, como string, caractere, ponto flutuante, um grande grupo de strings ou pode ser uma página da web e assim por diante.
Exemplo : 
 

# Perl program to demonstrate
# scalars variables
 
# a string scalar
$name = "Alex";
 
# Integer Scalar
$rollno = 13;
 
# a floating point scalar
$percentage = 87.65;
 
# to display the result
print "Name = $name\n";
print "Roll number = $rollno\n";
print "Percentage = $percentage\n";

Saída : 
 

Name = Alex
Roll number = 13
Percentage = 87.65

Escalares Numéricos

Variáveis ​​escalares numéricas contêm valores como números inteiros, inteiros (positivos e negativos), float (contendo ponto decimal). O exemplo a seguir demonstra diferentes tipos de variáveis ​​escalares numéricas em perl.
Exemplo : 
 

# Perl program to demonstrate various types
# of numerical scalar variables
 
# Positive integer numerical
# scalar variables
$intpositive = 25;
 
# Negative integer numerical
# scalar variables
$intnegative = -73;
 
# Floating point numerical
# scalar variables
$float = 23.5;
 
# In hexadecimal form
$hexadec = 0xcd;
 
# to display the result
print "Positive Integer = $intpositive\n";
print "Negative Integer = $intnegative\n";
print "Floating Point = $float\n";
print "Hexadecimal Form = $hexadec\n";

Saída : 
 

Positive Integer = 25
Negative Integer = -73
Floating Point = 23.5
Hexadecimal Form = 205

Escalares de string

Variáveis ​​escalares de string contêm valores como uma palavra (feita de caracteres diferentes), um grupo de palavras ou um parágrafo. O exemplo a seguir demonstra diferentes tipos de variáveis ​​escalares de string.
Exemplo :
 

# Perl program to demonstrate various types
# of string scalar variables
 
# String scalar
$alphastring = "GeeksforGeeks";
$numericstring = "17";
$alphanumeric = "gfg21";
 
 
#special character in string scalar
$specialstring = "^gfg";
 
# in single quotes
$singlequt = 'Hello Geeks';
 
# To display the result
print "String with alphabets = $alphastring\n";
print "String with numeric values = $numericstring\n";
print "String with alphanumeric values = $alphanumeric\n";
print "String within Single quotes = $singlequt\n";
print "String with special characters = $specialstring\n";

Saída : 
 

String with alphabets = GeeksforGeeks
String with numeric values = 17
String with alphanumeric values = gfg21
String within Single quotes = Hello Geeks
String with special characters = ^gfg