Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: my $a and our $aby Marshall (Canon) |
on Jan 06, 2016 at 07:15 UTC ( [id://1152048]=note: print w/replies, xml ) | Need Help?? |
First NEVER use $a or $b as a program variable as these have special meaning to Perl in terms of sorting. 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.
In Section
Seekers of Perl Wisdom
|
|