Click to See Complete Forum and Search --> : perl help for a newbie please


lydia
05-14-2003, 08:46 AM
if $x = 10 then the statement, if ($x++ == 10) { print("7\n")} is true, but could someone please explain to me in very plain terms, why it is true. I would have thought that it was false because 10 incremented by 1 = 11, thank you.

AdamGundry
05-14-2003, 09:57 AM
$x++ returns x (i.e. 10) then increments it by one, like doing this:

if ($x == 10)
then
$x = $x + 1

If you use ++$x, it first increments the variable then returns it.

Adam