Auto Increment or Decrement in Perl
by Geethalakshmi[ Edit ] 2010-09-17 14:01:16
Auto Increment or Decrement in Perl
The ++ or -- symbols are used to increment or decrement a variable by one. Depending on whether the ++ or -- comes before or after the variable determines when it is incremented.
$d = 17;
$e = ++$d; # $e and $d both equal 18
$d = 17;
$e = $d++; # $e = 17 and $d = 18
$x = 12;
--$x; # $x = 11
$y = $x-- # $y = 11, $x = 10