Explain the default scope of variables in perl?



Explain the default scope of variables in perl?..

Answer / Kumar Abhineet

In Perl, variables are scoped by lexical or dynamic context. Lexical variables are declared using my and have package level scope (defaulting to the current package). Dynamic variables (also known as global variables) don't have an explicit declaration and have file or subroutine scope. If a variable is used without being declared, it is treated as a dynamic variable.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More CGI Perl Interview Questions

How to read a file into a hash array?

1 Answers  


How to copy a file in perl?

1 Answers  


What is the use of -n and -p options?

1 Answers  


Explain 'grep' function.

1 Answers  


what is the main function of fork() in cgi programming?

1 Answers  


Why is it hard to call this function: sub y { "because" } ?

1 Answers  


Does Perl have reference type?

1 Answers  


Explain the difference between declarations of 'my' and 'local' variable scope in perl?

1 Answers  


How does polymorphism work in perl?

1 Answers  


How interpreter is used in perl?

1 Answers  


What does the qq{ } operator do?

1 Answers  


sort a word "system" in perl/shell without using built in functions output should be emssty

2 Answers   emc2,


Categories