From 32871e0191904585dfd8ebd1b14f72c539c93d98 Mon Sep 17 00:00:00 2001 From: bbrtj Date: Fri, 17 May 2024 19:57:49 +0200 Subject: [PATCH] Avoid using $_ when loading the commands from namespaces resolves #2175 --- lib/Mojolicious/Commands.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Mojolicious/Commands.pm b/lib/Mojolicious/Commands.pm index 22935931be..1ba30e278c 100644 --- a/lib/Mojolicious/Commands.pm +++ b/lib/Mojolicious/Commands.pm @@ -65,8 +65,10 @@ sub run { # Find all available commands my %all; for my $ns (@{$self->namespaces}) { - $all{substr $_, length "${ns}::"} //= $_->new->description - for grep { _command($_) } find_modules($ns), find_packages($ns); + for my $pkg (find_modules($ns), find_packages($ns)) { + next unless _command($pkg); + $all{substr $pkg, length "${ns}::"} //= $pkg->new->description; + } } my @rows;