Auto Increment or Decrement in Perl - Perl Views : 191
Tagged in : Perl
0 0
Send mail

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
By Geethalakshmi, On - 2010-09-17



    Login to add Comments .