# if you don't want to waste a _lot_ of timing guessing # at mistakes that Perl could have told you about # always put these two lines at the top of your scripts # even before any other use or package statements use strict; use warnings; package Foo::Bar::MyFrobincator; #full name is Foo::Bar::MyFrobincator::make_frobnicator sub make_frobnicator { ... } # full name: $Foo::Bar::MyFrobnicator::current_frobnicator our $current_frobnicator; # Perl knows we mean to call # Foo::Bar::MyFrobincator::make_frobnicator() # and that we want to assign the value to # $Foo::Bar::MyFrobnicator::current_frobnicator $current_frobnicator = make_frobnicator(); # change the active namespace to Foo::Baz package Foo::Baz; # fullname: Foo::Baz::bye sub bye { print "bye-bye\n"; } # Since the active namespace is now Foo::Baz # Perl now thinks you mean Foo::Baz::make_frobnicator() # which doesn't exist so you get an error make_frobnicator(); # so we need to use those awful long names - ugh! $Foo::Bar::MyFrobnicator::current_frobnicator = Foo::Bar::MyFrobincator::make_frobnicator() # but we can use a short name here # because bye is part of the Foo::Baz package # so Perl knows we mean Foo::Baz::bye() bye();