Mega Code Archive

 
Categories / Perl / Language Basics
 

Creating a Scalar

#The syntax for creating a scalar is: $variableName = <value>  #    in which value may be numeric (integer or float),    #    string   #    reference (scalar, array, hash, code, or package)    #    or boolean (True or False)            $scalar1 = 'this is a scalar';    # simple scalar assigned 'this is string'      $print = 10.0;                    # simple scalar assigned 10 (rounding is done)         $print = '10.0';                  # number that is also a string, assigned 10.0.         $scalar2 = "this is $print";      # interpolation, assigned 'this is 10.0'       $scalar3 = 'this is $print';      # non-interpolation, assigned 'this is $print'         $emptyString  = '';               # empty string.