http://www.perlmonks.org?node_id=605016


in reply to Storing variable coordinates in a matrix

Aside from a few extra parens, your problem is that you're storing the value in $x and $y as it is at the time @A is initialized. In order to get close to doing what you want you'd need to store references to $x and $y, but that won't let you store (say) $y+1 and you'd have an additional layer of dereferencing to get the values out.

The best compromise would be to make a sub which returns a new set of coords given a new $x and $y.