What are Perl Scalars?


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 −

Example

 Live Demo

#!/usr/bin/perl
$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";

Output

This will produce the following result −

Age = 25
Name = John Paul
Salary = 1445.5

Updated on: 28-Nov-2019

115 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements