Explain the difference between my and local?

Answers were Sorted based on User's Feedback



Explain the difference between my and local? ..

Answer / mahendra ratnakar

The variables declared with "my" can live only within the
block it was defined and cannot get its visibility
inherited functions called within that block, but one
defined with "local" can live within the block and have its
visibility in the functions called within that block.

Is This Answer Correct ?    12 Yes 4 No

Explain the difference between my and local? ..

Answer / sourisengupta

You can consider "my" as local and "local" as global
variable like C,C++.

The scope of "my" lies between the block only but if we
declare one varable global then we can asccess that from
the outside of the block also.

Is This Answer Correct ?    2 Yes 7 No

Post New Answer

More CGI Perl Interview Questions

What are scalars in perl?

0 Answers  


Differentiate between use and require, my and local, for and foreach and exec and system

0 Answers  


How to sort dates in Perl ?

1 Answers  


Can we load binary extension dynamically?

0 Answers  


How would you replace a char in string and how do you store the number of replacements?

2 Answers  






Comment on the scope of variables in perl.

0 Answers  


How and what are closures implemented in perl?

0 Answers  


How do you find the length of an array?

0 Answers  


How can you replace the characters from a string and save the number of replacements?

0 Answers  


Perl uses single or double quotes to surround a zero or more characters. Are the single(' ') or double quotes (" ") identical?

0 Answers  


What can be done for efficient parameter passing in perl?

0 Answers  


What?s your favorite module and why?

3 Answers  


Categories