You'll probably hear this a couple of times .. but telling us that a solution "didn't work" isn't a useful description of what did work.
Re-declaring new $x and $y variables makes local copies of those variables. Removing the my removes that issue, and should have solved the issue that you were having.
Show us the new code that "doesn't work" and we'll help you again -- but please, in future :) tell us more than just something "doesn't work".
Alex / talexb / Toronto
Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.