What is difference between: -
while( my($index, $value) = each @rocks )and
while((my $index,my $value) = each @rocks )I have read that "my" is used for creating private variables in a subroutine.
But if we use "use v5.14" then using "my" is compulsory whenever we are creating variable for the first time. Then in that case, if a variable is declared for the first time in a subroutine, it has to be private always(forcefully due to v5.14)
So how do we declare a non-private variable(global variable) in Subroutine.. At first it didn't make sense to me to have global variables in a subroutine.. But it is a topic in a book..
So is there any major signifance of "my" in Perl
And Yes.. I am Overwhelmed by how length of an array is easily replaced in a scalar context.. No function needed at all.. Wow!! :) :)
In reply to Use of "my" after Perl v5.14 by Rohit Jain
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |