"but the second part prints 11 when it should print 12"
And why should it print 12?
Your function takes $x as an argument and creates a reference to it called $value.
From that moment on $value is a direct link to $x. But your function does not do anything with the content of $value, it just returns $value+1. That means $value remains the same, so $x remains the same.