What are Perl Scalars?

PERLServer Side ProgrammingProgramming Scripts

A scalar is a single unit of data. That data might be an integer number, floating-point, a character, a string, a paragraph, or an entire web page.

Here is a simple example of using scalar variables −


 Live Demo

$age = 25;                # An integer assignment
$name = "John Paul";      # A string
$salary = 1445.50;        # A floating point

print "Age = $age\n";
print "Name = $name\n";
print "Salary = $salary\n";


This will produce the following result −

Age = 25
Name = John Paul
Salary = 1445.5
Published on 28-Nov-2019 12:43:29