top of page

Perl Scalars

 

Scalars are the most fundamental variables or storage types used in Perl.  Because of this, these are used more often than all the rest combined.  Scalars hold on piece of information; it can hold numbers, a word or a phrase.  A scalar can contain a full page of text if that's what you wanted to do, but it only ones one piece of information.

$scalar = "";

Scalars are defined using the symbol $ before it's name.  For example $name, $state, $color, etc. are all valid names.  Variable names should always start with a letter but you may use numbers and underscores inside them.

$age = 27;                                # An integer assignment
$name = "Thirumurugan";  # A string 
$height = 5.5;                         # A floating point

© 2015 Thirumurugan

bottom of page