in reply to Re^2: difference between my and local
in thread difference between my and local
Your example shows that you can only use local on global variablesWell, it more on anything that isn't a lexical variable. You can localize array elements for instance, even if the array itself is a lexical variable.
So why use my anywayBecause my creates lexically scoped variables. Variables that aren't visible outside of the block that declares them. local creates temporary values, which are only reset if a block gets exited.
The right question should be "why use local?".
|
|---|