in reply to Re: Re: Variable scoping outside subs
in thread Variable scoping outside subs

I think you are likely confused by the fact that $var seems to be legally declared before the subroutine, but the subroutine is called before $var is declared. And yet, in the subroutine, $var has not been initialized to 1.

In this case, the entire script is parsed and the my declaration is noted at compile time. The initialization of $var happens at runtime, except in your case you've exited before that point.

  • Comment on Re: Re: Re: Variable scoping outside subs