in reply to Re: Strange compile error?
in thread Strange compile error?

> Assignment is a right-to-left operation

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 == 123 

is 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

    I was talking about associativity (as in "right-to-left" operation). The table to which I referred lumps associativity and precedence together: there's not a lot I can do about that.

    — Ken

      But it doesn't matter which part of a statement is compiled first, be it by associativity or precedence or quantum flux.

      The docs are clear:

      The declared variable is not introduced (is not visible) until after the current statement.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      see Wikisyntax for the Monastery