When we publish our Perl module repository on GitHub, we might notice something peculiar in the "About"
section of our repository: GitHub doesn't recognize the Perl 5 license. This can be a bit
confusing, especially when we've explicitly stated the licensing in our LICENSE file.
Without properly defined license, GitHub ranks the quality of a repository lower. This is also unfortunate because it limits the "searchability" of our repository. GitHub cannot index it according to the license and users cannot search by license. This is today more important than ever before as many enterprises rule out open source projects purely on the grounds that their license is poorly managed.
The Problem: Two Licenses in One File
The standard Perl 5 license, as used by many modules, is a dual license: Artistic License (2.0) and GNU
General Public License (GPL) version 1 or later. Often, this is included in a single LICENSE file
in the repository root.
GitHub's license detection mechanism, powered by Licensee,
is designed to identify a single, clear license. When it encounters a file with two distinct
licenses concatenated, it fails to make a definitive identification.
Here's an example of a repository where GitHub doesn't recognize the license.
Notice the missing license badge in the "About" section:

Also the "quick select" banner above Readme file does not acknowledge which license there is.

The Solution: Separate License Files
The simplest and most effective solution is to provide each license in its own dedicated file. This
allows Licensee to easily identify and display both licenses. This is perfectly valid
because the Perl 5 license explicitly allows for distribution under either the Artistic License or the GPL.
Providing both licenses separately simply makes it clearer which licenses apply and how they are presented.
(The other reason for having multiple licenses is situation where different parts of the repository
are under different licenses. But this is not our problem here.)
For example, instead of a single LICENSE file containing both, we would have:
- LICENSE-Artistic-2.0
- LICENSE-GPL-3
Let's look at an example from my own env-assert repository. In this repository, I've separated the licenses into LICENSE-Artistic-2.0 and LICENSE-GPL-3.
And here's how GitHub's "About" section looks for env-assert, clearly recognizing both licenses:

As we can see, GitHub now correctly identifies "Artistic-2.0" and "GPL-3.0" as the licenses for the
project.
Same is also visible in the "quick select" bar:

Automating with Software::Policies and Dist::Zilla::Plugin::Software::Policies
Manually creating and maintaining these separate license files for every module can be tedious.
Fortunately, there is a way to automate this process if you are using Dist::Zilla for authoring.
Dist::Zilla::Plugin::Software::Policies
If we're using Dist::Zilla for our module authoring,
Dist-Zilla-Plugin-Software-Policies
can automatically check that we have the correct License files. It uses Dist::Zilla's
internal variable licence to determine the correct license files.
The Dist::Zilla plugin uses Software-Policies
as a backend to do the heavy lifting.
Software::Policies
Software::Policies is a module that provides a
framework for defining and enforcing software policies, including licensing. It comes with a
pre-defined policy for Perl 5's double license. It can also generate other policy files,
such as CONTRIBUTING.md, CODE_OF_CONDUCT.md, and SECURITY.md.
By using Software::Policies, we can programmatically check for the presence and content of our
license files.
This approach not only solves the GitHub license detection problem but also helps us maintain
consistent and correct licensing across all our Perl modules, integrating it directly into our build
workflow.
By configuring this plugin in our dist.ini, we can ensure that our distribution always includes
the correct and properly formatted license files, making GitHub (and other license scanners) happy.
Here's a simplified example of how we might configure it in our dist.ini:
[Software::Policies / License]
policy_attribute = perl_5_double_license = true
[Test::Software::Policies]
include_policy = License
This configuration tells Dist::Zilla plugin Test::Software::Policies to apply the Perl
licensing policy, which typically means Artistic License 2.0 and GPL. When we build our
distribution with Dist::Zilla, the plugin will create a test file checks for the existence
and content of the LICENSE-Artistic-2.0 and LICENSE-GPL-3 files.
During testing phase, when running dzil test or dzil release, the test files will be run
and if the license files are missing or incorrect, the tests will fail.
To generate the files, we can run the command dzil policies License or just dzil policies.
This will create the files according to config in dist.ini, the [Software::Policies / License]
part of dist.ini.
We cannot create the files automatically during build because then they will only be included
in the release, not in the repository. It is precisely in the repository that we need them
for GitHub's sake. So the process to create or update the license files has to have
this small manual stage.