http://qs1969.pair.com?node_id=1146650


in reply to Behavior of 'our' variables in the package-namespace

Without the BEGIN your code looks somewhat like:

my $foobar_o = Foo::Bar->new("object o"); printf "%s\n", $foobar_o->text(1); # some random stuff our $data = { 1 => "one", 2 => "two", 100 => "one hundred", }; # some more random stuff

from which you can see the initialization of $data doesn't happen until after the call to text. Nothing to do with our versus my. Put the package at the top of the file and educate your users, or stick with the BEGIN. In either case "my" would be better than "our" in the context shown.

Premature optimization is the root of all job security