in reply to print behavior

The interpreter is behaving as if it is evaluating $x++ before it prints anything out. The initial value of $x is 0. So, when $x++ is evaluated, $x then becomes 1.

Try this:

print "x=" . $x . "\n"; print "x++=" . $x++ . "\n";
You should get this output, which is more like what you expect.
x=0 x++=0