6.1. Use and Abuse
The rule of the thumb is that for general scoping, local
should not be used instead of my
, which is safer and better. You may still encounter some code using local in the wild, but assuming you need to maintain it, this code should be revamped to use my
instead.
For more information refer to:
- Mark Jason Dominus' "Coping With Scoping" - a general and comprehensive discussion.
- "Seven Useful Uses of
local
" - also by Mark Jason Dominus. - A Linux-IL post explaining the difference between
my
andlocal
- by Shlomi Fish.