Every distribution on CPAN can include a META.yml and a META.json file. They should hold the same information, META.json is just the newer format. So you'll find a lot more distributions with only META.yml and you'll find a few, probably very old distribution with no META file at all.
The META files can both have a field indicating the license of the distribution.
Having the license information in the META files makes it very easy for automated tools to check if a set of modules have a certain set of licenses.
As the META files are usually generated automatically when the distribution is released by the author, I am going to show you how you can tell the 4 main packaging systems to include the license field.
In the examples I'll use the most common, so called, Perl license:
If you are using ExtUtils::MakeMaker add the following to your Makefile.PL as parameter in the WriteMakefile function:
'LICENSE' => 'perl',
If you want to make sure older versions of ExtUtils::MakeMaker won't give warnings on unknown LICENSE field, you can use the following code:
($ExtUtils::MakeMaker::VERSION >= 6.3002 ? ('LICENSE' => 'perl', ) : ()),
The version distributed with perl 5.8.8 is 6.30 thus it does not yet contain this feature. The best if you could upgrade ExtUtils::MakeMaker.
If you are using Module::Build, add the following to Build.PL, in the Module::Build->new call:
license => 'perl',
If you are using Module::Install add the following to Makefile.PL:
If you are using Dist::Zilla, just add the following entry to the dist.ini file:
license = Perl_5
In order to check the current list of valid options for the license field, check the CPAN::Meta specification.
Copyright and Licensing
According to the CPAN Licensing Guidelines of The Perl Foundation, it is required to have the license information in the META files.
There are of course other required elements of the licensing. This article only focuses on the entry in the META files.