Increment in Perl

Find this useful? Support us: Star on GitHub 6
Category: Number | Language: Perl

In Perl, the increment operator ++ can be used to increment a number by one.

Here are some examples:

my $number = 5;

$number++; # increments $number by 1

print $number; # output: 6

$number += 3; # increments $number by 3

print $number; # output: 9

In the above example, the variable $number is initially set to 5. The ++ operator is then used to increment the value of $number by 1. The resulting value of $number is then printed to the screen.

In the second example, the += operator is used instead of ++ to increment the value of $number by 3. The resulting value of $number is then printed to the screen.