in reply to my and local differences

Take a look at mjd's article Coping with Scoping. It has a good discussion of the differences between my and local. Read Seven Useful Uses of local for when to use local.