in reply to Re: Strange compile error?
in thread Strange compile error?
That's right, but sorry you are overcomplicating things.
Precedence isn't relevant here:
DB<1> use strict; my $N = $N; Global symbol "$N" requires explicit package
Declarations are only effective after the statement, in this case behind the semicolon.
This was done to allow accessing equally named variables from a surrounding scope.
See perlsub#Private-Variables-via-my()
The declared variable is not introduced (is not visible) until after the current statement. Thus,
my $x = $x;can be used to initialize the new $x with the value of the old $x, and the expression
my $x = 123 and $x == 123is false unless the old $x happened to have the value 123.
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Strange compile error?
by kcott (Archbishop) on Apr 29, 2024 at 23:08 UTC | |
by LanX (Saint) on Apr 30, 2024 at 00:19 UTC |