my keyword in Perl declares the listed variable to be local to the enclosing block in which it is defined. The purpose of my is to define static scoping. This can be used to use the same variable name multiple times but with different values.
Note: To specify more than one variable under my keyword, parentheses are used.
Syntax: my variable
variable: to be defined as local
does not return any value.
Geeks for Geeks This is in Function Geeks for Geeks Geeks for Geeks
Welcome to Geeks Let's GO Geeky!!! Welcome to Geeks Welcome to Geeks
How to define dynamic scoping?
The opposite of “my” is “local”. The local keyword defines dynamic scoping.
- Perl | scalar keyword
- Perl | Basic Syntax of a Perl Program
- Perl Tutorial - Learn Perl With Examples
- Perl | split() Function
- Perl | chomp() Function
- Perl | Backtracking in Regular Expression
- Perl | Searching in a File using regex
- Perl | Operators | Set - 1
- Perl | lt operator
- Perl | chop() Function
- Perl | rename() Function
- Perl | Subroutines or Functions
- Perl | Decision Making (if, if-else, Nested–if, if-elsif ladder, unless, unless-else, unless-elsif)
- Perl | Scalars
- Perl | Loops (for, foreach, while, do...while, until, Nested loops)
- Number Guessing Game using Perl
- Perl | Comparing Scalars
- Perl | Removing leading and trailing white spaces (trim)
- Perl | String functions (length, lc, uc, index, rindex)
- Perl | Arrays
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.