#!/usr/local/bin/perlWhen we run the above program we get the following output:
$valueAdd = 1 + 1;
$valueSubtract = 4 - 1;
$valueMultiply = 2 * 2;
$valueDivide = 10 / 2;
print "$valueAdd\n";
print "$valueSubtract\n";
print "$valueMultiply\n";
print "$valueDivide\n";
$ ./simpleProgram.plLets take a look at another example using both text and numerical scalars:
2
3
4
5
$
#!/usr/local/bin/perlThis will output:
$textSample = "This is a string.\n";
$numberOne = 5;
$numberTwo = 3;
print $textSample;
print "$numberOne + $numberTwo = " . ($numberOne + $numberTwo) . "\n";
print "$numberOne * $numberTwo = " . ($numberOne * $numberTwo) . "\n";
$ ./simpleProgram.plI've added in one last operator in the above example - the concatenation operator, or the period. It acts as a sort of bridge between two strings to glue them together. In the example above, you can see that I use it to join the first part of the string and the newline with a small mathematical calculation.
This is a string.
5 + 3 = 8
5 * 3 = 15
$
While this may seem like a lot of information to process and take away, don't worry. We will go over more of these topics in greater detail later. For now, there are only a few important things you need to remember:
- A scalar is the first of 3 basic data types in Perl.
- A scalar is a virtual box that holds a single piece of data.
- You can use operators to modify the data within your variable, and access it using the $variableName you designate.

