in reply to Re: Frustrating Error: "Global symbol requires explicit package name" - Can't see why?
in thread Frustrating Error: "Global symbol requires explicit package name" - Can't see why?

Yeah nothing specific about threads, just the fact that my declarations only start being effective after the next semicolon.

This was done to allow constructs like

my $x = $x++;

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

  • Comment on Re^2: Frustrating Error: "Global symbol requires explicit package name" - Can't see why?
  • Download Code

Replies are listed 'Best First'.
Re^3: Frustrating Error: "Global symbol requires explicit package name" - Can't see why?
by AnomalousMonk (Archbishop) on Aug 25, 2015 at 15:12 UTC

    When I first read LanX's reply, I was confused because the statement all on its own is an error. But LanX /msg-ed me that the rule allows access to same-named lexicals in surrounding scopes:

    c:\@Work\Perl\monks>perl -wMstrict -le "my $x = 42; if ($x) { my $x = $x++; print $x; } print $x; " 42 43
    Now I understand.


    Give a man a fish:  <%-{-{-{-<