Explain the difference between declarations of 'my' and 'local' variable scope in perl?
Answer / Rukmani
In Perl, the 'my' keyword creates a lexical (or private) variable that is only accessible within the current scope. The variable will be destroyed when the subroutine or block ends. On the other hand, 'local' declares a dynamic (or package) variable that can be accessed by any function in the same package. However, unlike 'my', 'local' variables retain their values between function calls.
| Is This Answer Correct ? | 0 Yes | 0 No |
How to open a directory in perl?
How do you open a file for writing?
What is warn function in perl?
What does -> symbol indicates in Perl?
“The methods defined in the parent class will always override the methods defined in the base class”. What does this statement means?
How can you replace the characters from a string and save the number of replacements?
What does file test operators do in perl?
Write a program to show the process of spawning a child process
What is the easiest way to download the contents of a URL with Perl?
Does Perl have reference type?
What is the difference between chop & chomp functions in perl?
10 Answers Cap Gemini, DELL, Electronic Data, TCS,
You want to empty an array. How would you do that?