Re: [PATCH] get_maintainer: lazy load JSON::PP only when --json is used

From: Joe Perches

Date: Fri Oct 30 2026 - 12:10:34 EST


On Fri, 2026-10-30 at 16:43 +0100, Oleg Nesterov wrote:
> After commit 09d8b39563e8 ("get_maintainer: add --json output mode"),
> I can no longer use get_maintainer.pl; it fails at compile time

?

Just verifying that you mean when using perl directly and
not something like perlcc.

> if JSON::PP is not installed even when --json is not requested.

What version of perl are you using?

I believe JSON is bundled since perl 5.14

> This module is only needed with the --json option. Use "require" to
> load this module dynamically inside the "if ($json)" block instead.

The patch may be sensible but could fail the same way
if you used the --json option with your version.

> diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
[]
> @@ -21,7 +21,6 @@ use Cwd;
> use File::Find;
> use File::Spec::Functions;
> use open qw(:std :encoding(UTF-8));
> -use JSON::PP;
>
> my $cur_path = fastgetcwd() . '/';
> my $lk_path = "./";
> @@ -685,6 +684,7 @@ if ($json) {
> $result{web} = \@web if ($web);
> $result{bug} = \@bug if ($bug);
>
> + require JSON::PP;

style nit:
I likely would have placed this require immediately after the
if ($json) {

> my $json_encoder = JSON::PP->new->canonical->utf8;
> print($json_encoder->encode(\%result) . "\n");
> } else {
>
> ```