in reply to my $a and our $a
Almost all of your variables should be "my whatever"...that means 99.9%. These are lexically scoped variables within a single compilation unit. The addresses of these variables are not fixed, they are allocated on the stack. The same name can be reused again and again within different loops. "my $name" in one loop is not the same as "my $name" in another loop.
An "our" variable is different. This is like a C static. This variable is global and goes into a special symbol table. These variables can be accessed by other modules (there is no way to do that with a "my" variable).
"our" variables should be used very sparingly and for good reasons.
|
|---|