Explain the difference between my and local?
Answers were Sorted based on User's Feedback
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 |
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 |
while(my($key, $value) = each(%hash) ) { print "$key => $value\n"; } my($key, $value); while(($key, $value) = each(%hash) ) { print "$key => $value\n"; } What is the different between these two code in case of "my" usage ?
Which functions in perl allows you to include a module file. State their differences.
What's the difference between /^Foo/s and /^Foo/?
Suppose an array contains @arraycontent=(‘ab’, ‘cd’, ‘ef’, ‘gh’). How to print all the contents of the given array?
Explain the functioning of conditional structures in perl.
Explain arrays in perl.
Why Perl aliases are considered to be faster than references?
Who created perl?
What are the functions that can be performed using cgi program?
What are the various flags/arguments that can be used while executing a perl program?
How do find the length of an array?
List the data types that Perl can handle?