You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ perldoc -f my
my VARLIST
my TYPE VARLIST
my VARLIST : ATTRS
my TYPE VARLIST : ATTRS
A "my" declares the listed variables to be local (lexically) to
the enclosing block, file, or "eval"...
OK but be sure to mention when its OK, and when not:
$ cat e.pl
use strict;
use warnings 'all';
my $e = 1;
my $e = 1;
{
$e = 1;
my $e = 1;
}
$ perl e.pl
"my" variable $e masks earlier declaration in same scope at e.pl line 4.
So only one of the three my's is bad.
So perldoc -f my needs to tell the user why. (Don't tell me why.)
Maybe the details are in perlsub. But we aren't using subroutines here,
so the user won't look there on his own.
The text was updated successfully, but these errors were encountered:
Some text such as the following? (Which hopefully matches up with the error description in perldiag.pod.) Variables should not subsequently be redeclared in the same scope or statement.
jkeenan
changed the title
[doc]
[doc] Request better documentation of "my"
Dec 9, 2020
OK but be sure to mention when its OK, and when not:
So only one of the three my's is bad.
So perldoc -f my needs to tell the user why. (Don't tell me why.)
Maybe the details are in perlsub. But we aren't using subroutines here,
so the user won't look there on his own.
The text was updated successfully, but these errors were encountered: