Scalar Variable in Perl

 

Hello,

 

The following post will explain you the rules and example to use scalar variable in perl language.

Rules:
Scalar variable can be used to define single or multiple values.

 

Here in the following example, I have declared the variable $firstname, $lastname and $age as single value and $Designation as multiple values inside “” double quotation.

#!/usr/bin/perl -w
# Example script to declare Scalar variable

$firstname = "Siranjeevi";
$lastname = "Rajendran";
$age = 24;
$Designation = "Systems Engineer";
print "$firstname $lastname with age $age is working as $Designation\n";

#END

The output would be

Siranjeevi Rajendran with age 24 is working as Systems Engineer

Thank you for viewing helpinlinux.com

Leave a Reply

Protected by WP Anti Spam