help logoLON-CAPA Help


Variables can be used later in the same script. For instance, we can add another line below the $variable line as such:

$variable2 = $variable+2;

Now there is a variable called $variable2 with the the number "5" as its value.

Variables can also be used in strings, which are a sequence of letters. The underlying language of the script, Perl, has a very large number of ways of using variables in strings, but the easiest and most common way is to use normal double-quotes and just spell out the name of the variable you want to use in the string, like this:

$stringVar = "I have a variable with the value $variable.";

This will put the string "I have a variable with the value 3." into the variable named "stringVar".