I keep seeing the "my" keyword in front of variable names in example Perl scripts online but I have no idea what it means. I tried reading the manual pages and other sites online but I'm having difficulty discerning what it is for given the difference between how I see it used and the manual.
For example, its used to get the length of the array in this post: Find size of an array in Perl
But the manual says:
A my declares the listed variables to be local (lexically) to the enclosing block, file, or eval. If more than one value is listed, the list must be placed in parentheses.
What does it do and how is it used?
转载于:https://stackoverflow.com/questions/20889609/how-should-i-use-the-my-keyword-in-perl