Programming Languages
C++
Subjective
Mar 13, 2013
How can you define “my” variables scope in Perl and how it is different from “local” variable scope?
Detailed Explanation
print "Outside the block, $test = $test ";
print "Outside the block, $:: test = $::test ";
Output:
In block, $test = 3
In block, $::test = 2.3456
Outside the block, $test = 2.3456
Outside the block, $::test = 2.3456
The scope of “my” variable visibility is in the block only but if we declare one variable local then we can access that from the outside of the block also. ‘my’ creates a new variable, ‘local’ temporarily amends the value of a variable.
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts