by
Jeremy Canfield |
Updated: March 31st, 2021
| Perl (Scripting) articles

Here is a basic example of how to add two numbers.

```
my $sum = (1 + 1);
print "$sum \n";
```

Which should return the following.

`2`

**Increment**

++ can be used to increment a value by one.

```
my $value = 1;
++$value;
print "$value \n";
```

Which should return the following.

`2`

**Appending**

+= can be used to add to an already set value.

```
$i = 1;
$i += 2;
print "$i \n";
```

Which should return the following.

`3`

**Decimal numbers**

By default, decimal will be used.

```
my $sum = (1.1 + 1.1);
print "$sum \n";
```

Which should return the following.

`2.2`

**Whole numbers**

The integer module can be used to round to whole numbers.

```
use integer;
my $sum = (1.1 + 1.1);
print "$sum \n";
```

Which should return the following.

`2`

Web design by yours truely - me, myself, and I | jeremy.canfield@freekb.net |