http://www.perlmonks.org?node_id=11139068


in reply to Faster with my keyword or no ?

We strongly recommend that you always use strict in every script. Under strict, you must declare all your variables (my for lexical, our for global). Without strict, all variables default to 'package'. Your question becomes "Which type of variable is faster?" I doubt that it makes much difference.

In general, It is better to have a program that is easy to maintain than it is to have one that is marginally faster. ('strict' and 'my' offer several advantages to the maintainer.) The usual recommendation is to not even consider execution speed until you have a complete program that works correctly, but is unacceptably slow. At that point, profile it to identify the problem area. Write several versions of this code. Benchmark each with realistic data. (You will almost always be surprised by the result). Resist the temptation to make "easy changes" to speed-up other sections. Even a big improvement will make little difference in your complete program.

Bill