in reply to package variable scope

Our is (like my ) lexically scoped, your last print puts the last $VAR.

you should have called main::printit()

Think of our as an aliasing mechanism, qualifying a $var as $__PACKAGE__::var for the rest of the scope, but taking the package at declaration time!

To be able to limit the scope use {curlies}.

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

update

And is very clearly documented:

An our declaration declares an alias for a package variable that will be visible across its entire lexical scope, even across package boundaries. The package in which the variable is entered is determined at the point of the declaration, not at the point of use. This means the following behavior holds:

package Foo; our $bar; # declares $Foo::bar for rest of lexical scope $bar = 20; package Bar; print $bar; # prints 20, as it refers to $Foo::bar