The role of Perl variables I, our, local and global variables _perl
Create an Alibaba Cloud account, and get a free trial with 40+ products, enterprise account can enjoy a free trial worth $1200. Register Now!
Perl-defined variables are global by default
1) My role: the name and value of the variable are limited to a range, that is, the variable can only be the module or function
You can see this variable, a layer or a lower layer is not visible.
2 Our role: To limit the variable name to a range, in fact, is to explicitly declare a "global variable", although it is in a
Modules or functions inside the definition, the outside can also be accessed, if it has been declared, again with our, express here and previously declared our variables
is the same one.
3 Local role: The value is limited to a certain range, which differs from my, which includes this layer and the lower level of this layer,
However, the previous layer of this layer is not accessible.
4) Global Variables
Use VARs QW ($szVersionCode, $szVersionNmae) to define variables $szversioncode and $szversionname
into global variables. Its role and our role is equal. Because of its presence in my presence, our previous period of history, so that we can now
See some books on the definition of global variables also continue this definition method, but I suggest: Define global variables or use our keyword to define.
PS: When Perl is not using use strict ' vars ', we can use any variable without the need to implement the definition.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to email@example.com. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
and provide relevant evidence. A staff member will contact you within 5 working days.