our $AUTHORITY

So what is the business with the following global variable I keep seeing in CPAN modules these days?

our $AUTHORITY;

So I searched a bit to figure it out, and found it made its way from Perl 6. A description of its use in Perl 6 can be found in Synopsis 11: Modules. Essentially Perl 6 saw that there would be no reason why there can’t be more than one module named Foo::Bar. You can already designate a minimum version required of a module, and you still can in Perl 6, but they saw that Foo::Bar is just a short name for the module. Its full name includes more parts, including the authority. So to load up the Foo::Bar I wrote in CPAN (note: I have no such module), you would say:

use Foo::Bar:auth<cpan:DOUGDUDE>;

When in the Foo::Bar module I specify:

our $AUTHORITY = 'cpan:DOUGDUDE';

Leave a Reply