in reply to Question on "my" in the variables
Simply stated, “the real objective here is:
When you are about to shoot yourself in the foot(!!) ... it is much better for the computer to go ‘click’ than to go ‘BANG!!’.
If you “simply” declare all variables to be global, then the ever-accommodating “I presume that you know what you are doing” Perl language will generally try its best to accommodate you. However, you probably would much prefer that it should detect as many of your errors as possible. Instead of telling Perl that variables should have the widest possible scope, you probably want to be as specific as possible, and then to use strict; use warnings; so that the computer will have the greatest possible chance of detecting your unintended screw-ups. Instead of letting Perl run amok, let Perl decline to run your code at all.
Execution-speed is really not the point: no one is in a hurry to get the wrong answers (or, far worse, “unexplainable but obviously-wrong behaviors”) quickly.