Yeah, "my" basically makes the variable only valid within the current block of code. If you remove the "my", then it can global to the whole script. Using "my" outside of a block (such as sub EVENT or anything with brackets) will just not let it work properly by perl design. I am not exactly sure why it even works for a single NPC, but either way it is not recommended.
When you have a static array like that which isn't being altered in the script, it is fine to define it outside of the subs as long as you leave off the "my". However, if you have a variable outside of the subs that does get modified by the script, it can effect all NPCs that use that same script since it is global.
It can sometime be tricky to get the right results when working with stuff like default.pl which will be applied to a large number of NPCs. Understanding the functionality of "my" and global variables can help a lot.
|