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

Why do we use "use strict" in perl?

0 Answers  


What does Perl do if you try to exploit the execve(2) race involving setuid scripts?

0 Answers  


what are prefix dereferencer and list them out?

0 Answers  


what are the strategies followed for multiple form interaction in cgi programs?

0 Answers  


Why Perl aliases are considered to be faster than references?

0 Answers  






What can be done for efficient parameter passing in perl?

0 Answers  


How would you ensure the re-use and maximum readability of your perl code?

0 Answers  


How to find the length of an array in perl?

0 Answers  


What are stdin, stdout and stderr?

0 Answers  


I have one question regarding to eval function. I know eval function is use for error checking but I am not able to understand below line. eval \'exec perl -S $0 ${1+\"$@\"}\' if 0; $0 for script name $@ set if error occur

0 Answers  


what r the future opportunities in PERL/LINUX after 3 years ??

3 Answers  


What happens when you return a reference to a private variable?

0 Answers  


Categories