Online Learning Applications for Technical English


Home
Syllabus
Assignments

Instructor



Producing Homepages

Scalar variables

A scalar variable stores one value item such as a number or string. In Perl, scalar variable names begin with a dollar sign, e.g., $i, $DATA_FILENAME, etc. We assign scalar values as follows:

  $i = 1;                             # give $i the value of 1
  $DATA_FILENAME = 'attendance.dat';  # give $DATA_FILENAME the
                                      #  14-character string 'attendance.dat';
  $j = $i;                            # give $j the value of $i (1)
  $j = $j + 1;                        # increment the current value of $j
                                      #  and put the result back in $j (2)
  $PATH = "c:\$DATA_FILENAME";        # $PATH is "c:\attendance.dat"

Note 1: You can use letters, digits, or the underscore character in the scalar variable name, but do not use a digit right after the dollar sign.

[ Back ]